Springdoc-openapi - Is there any way to override default value as null or empty in the POST request? - springdoc

I am using Spring Boot and Open API 3. Through OAS2 Swagger when I make a POST request, I see that all String fields are coming default value as a Spring and I dont see a way to remove it, either through SpringDoc Open UI nor through code.
{
"firstName": "string",
"lastName": "string",
"age": 0,
"email": "string",
"address1": "string",
"address2": "string",
"address3": "string",
"telephone" : "0",
"department" : "string",
.....
}
Here consumer not willing to remove the string from field while making the request. Is there any way
1) If we can remove "string" as a value and set null or "" as default value ?
2) Is there any way if we can read the custom object and reset all values to null where it finds the "string"?

You could use
#Schema(example = "<your example here>")
to provide another example for swagger-ui.
For "" you can do (yes, it's a space):
#Schema(example = " ")

Related

Webbook and Corresponding Data in Deluge

Somewhat new to coding but I'm attempting to write a flow in ZOHO in deluge where a webhook sends back data containing a property ID and I need to map that data via an API call with the ID as a "path parameter" to return the actual property address.
So far I've used invoke URL with my API key but after that, I'm not sure the best way to insert the webhook ID into the API request and map the data to return the information I need which is simply the Unit number and full address detail
Example JSON data"
{
"Id": 0,
"AssociationId": 0,
"AssociationName": "string",
"UnitNumber": "string",
"Address": {
"AddressLine1": "string",
"AddressLine2": "string",
"AddressLine3": "string",
"City": "string",
"State": "string",
"PostalCode": "string",
"Country": "UnitedStates"
},
"UnitBedrooms": "NotSet",
"UnitBathrooms": "NotSet",
"UnitSize": 0
}

How to add Response Card in Lex using PutIntent method?

I am trying to add a Response Card in lex using putIntent(). In AWS the putIntent method accepts responseCard as a String but how to add title, subTitle, ImageUrl, button values, and button names at the time of creating an Intent using response card parameter through putIntent?
So can anyone please help me to solve the issue. Provide a sample input where response card as String which can contain the above attributes. Thank you in advance.
"slots": [
{
"description": "string",
"name": "string",
"priority": number,
"responseCard": "string",
"sampleUtterances": [ "string" ],
"slotConstraint": "string",
"slotType": "string",
"slotTypeVersion": "string",
"valueElicitationPrompt": {
"maxAttempts": number,
"messages": [
{
"content": "string",
"contentType": "string",
"groupNumber": number
}
],
"responseCard": "string" --(how to pass title, imageUrl and other attributes)
}
Looks like you got the correct slots portion of the full response format from Lex API PutIntent.
The responseCard format can be found at Lambda Input Response Format
"responseCard": {
"version": integer-value,
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
Assuming you create that responseCard object in the format above as a variable named responseCard, then to make that object a string to pass in PutIntent try:
JSON.stringify(responseCard) if using Node.js, or
json.dumps(responseCard, separators=(',',':')) if using Python.

Compare object property to validate json schema in same object

I have a very simple object like so:
{
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"required": [
"firstName",
"lastName"
],
"properties": {
"firstName": {
"type": "string",
"title": "First name"
},
"lastName": {
"type": "string",
"title": "Last name",
"minLength": "{'$ref': '/properties/firstName'}"
},
}
On the property of LastName I would like to compare a value with a value of the property next to it. I am actually comparing integers so in actuality my real world example is even easier, just minimum and maximum.
I looked at the json schema spec here and it seemed like this should be doable, and have tried using relative paths and the $ref object.
Is this not possible?
The reference is here: https://www.rfc-editor.org/rfc/rfc6901
I am using react-jsonschema-form but I don't see where that would effect this.
There are a few of reasons why this doesn't work. The primary reason is that $ref refers to the schema, not the data being validated. There was talk of adding a $data keyword to JSON Schema that would allow referencing the instance data, but I don't think that will even happen.

How to preserve Json Object Order in Robot Framework

I am working with an API that requires the json key value pairs to be ordered when creating resources. The API provides a method (called new) that allows you to make a GET request that will return an object model. I would like to update the model with values within my RobotFramework test cases. Is there a native way within Robot Framework to make a GET request and preserve the json object order sent by the server? Here's an example of the JSON response to the GET new method:
{
"account": {
"#id": "",
"#uri": "",
"#oldID": "",
"person": {
"#id": "",
"#uri": ""
},
"accountType": {
"#id": "",
"#uri": "",
"name": null
},
"accountName": "",
"createdDate": null,
"createdByPerson": {
"#id": "",
"#uri": ""
},
"lastUpdatedDate": null,
"lastUpdatedByPerson": {
"#id": "",
"#uri": ""
}
}
}
If I use the following, the key values automatically get sorted:
${r}= GET Request MySession /accounts/new
For anyone else who needs ordered JSON in robot framework, I was able to achieve it with the following (thanks to help in the comments):
&{object}= Evaluate json.loads('''${r.text}''', object_pairs_hook=collections.OrderedDict) modules=json, collections
Though, ultimately this kind of logic is probably best suited in a custom helper library.

swagger JSON produces null value it stops UI

I am using swaggerspring mvc -1.0.2 and jackson-databind 2.6.3.why it produce null value.how stop it?.it stopping swagger UI.
JSON
{
"parameterType": {
"absoluteType": "array"
},
"name": "file",
"description": "Pass File as input",
"defaultValue": "",
"required": true,
"allowMultiple": false,
"allowableValues": null,
"paramType": "query",
"paramAccess": null
}
You need to configure your JSON mapper to not write null values:
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html#howto-customize-the-jackson-objectmapper
And adding the specific serialization option is like such:
spring.jackson.serialization-inclusion:non_null