it appears that the problem lies with the JSON Schema definition using the “type” keyword for certain fields that can be of more than one data type, including “null.”
The behavior you observed is correct and expected according to the JSON Schema specifications. When you define a field with multiple types (e.g., “integer” and “null”), the JSON Schema indicates that the field can either be an “integer” or “null.” This results in the JSON document type being created as an “object” with the possibility of having either an “integer” value or a “null” value.
To resolve this issue and create the JSON document type properly, you can use the “oneOf” keyword in your JSON Schema. The “oneOf” keyword specifies an array of subschemas, and a given data instance must be valid against exactly one of these subschemas.
Here’s how you can modify your JSON Schema using “oneOf”:
{
“$id”: “example com/person.schema.json”,
“$schema”: “json-schema org/draft-07/schema#”,
“title”: “Person”,
“type”: “object”,
“properties”: {
“firstName”: {
“type”: “string”,
“description”: “The person’s first name.”
},
“lastName”: {
“oneOf”: [
{
“type”: “string”,
“description”: “The person’s last name.”
},
{
“type”: “null”
}
]
},
“age”: {
“description”: “Age in years which must be equal to or greater than zero.”,
“type”: “integer”,
“minimum”: 0
}
}
}
By using “oneOf” in the “lastName” property, you specify that the field can be either a “string” or “null.” This will ensure that the JSON document type is created correctly with the expected field types.
Remember to validate your JSON Schema using a JSON Schema validator after making the changes to ensure its correctness before using it in your application. If I made a mistake and couldn’t help you, you may want to seek help from experts in custom software development
#Integration-Server-and-ESB#JSON#Service-Designer#schema#webMethods#JSON-schema#designer