Swagger - Invalid JSON errors - json

I'm just starting with Swagger UI and I'm trying to understand how it works.
So far I've entered some JSON (manually) and this is the result:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "PhakeApps API",
"contact": {
"name": "PhakeApps API team",
"url": "http://phakeapps.com/"
},
"license": {
"name": "Creative Commons 4.0 International",
"url": "http://creativecommons.org/licenses/by/4.0/"
}
},
"host": "api.phakeapps.com",
"basePath": "/v1",
"schemes": [
"http"
],
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"paths": {
"/places/search": {
"post": {
"tags": [
"Places"
],
"description": "Search for (a) place(s) <br /><br /> <b>id</b> - The ID of the request. <br /> <b>api_key</b> - API Key for the platform the request is sent. <i>Currently, not required.</i> <br /> <b>Params</b> - Required. <i>See model & model schema.</i>",
"operationId": "PlacesSearch",
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"parameters": [
{
"name": "request",
"in": "body",
"paramType": "body",
"description": "Object containing the <u>id</u>, <u>api_key</u> and certain <u>params</u>.",
"required": true,
"schema": {
"$ref": "#/definitions/Search"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/PlacesResult"
}
},
"403": {
"description": "Validation error or Server Failure",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
},
"definitions": {
"PlacesResult": {
"required": [
"data",
"id",
"code"
],
"properties": {
"data": {
"$ref": "#/definitions/Places"
},
"id": {
"type": "integer",
"format": "int32"
},
"code": {
"type": "integer",
"format": "int32"
}
}
},
"Places": {
"required": [
"places"
],
"properties": {
"places": {
"$ref": "#/definitions/Place"
}
}
},
"City": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Neighbourhood": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Cuisine": {
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"Place": {
"required": [
"id",
"name",
"city",
"neighbourhood",
"address",
"cuisine",
"price",
"photos_cnt",
"lat",
"lng",
"is_fav"
],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"city": {
"type": "array",
"items": {
"$ref": "#/definitions/City"
}
},
"neighbourhood": {
"type": "array",
"items": {
"$ref": "#/definitions/Neighbourhood"
}
},
"address": {
"type": "string"
},
"cuisine": {
"type": "array",
"items": {
"$ref": "#/definitions/Cuisine"
}
},
"price": {
"type": "integer",
"format": "int32"
},
"photos_cnt": {
"type": "integer",
"format": "int32"
},
"lat": {
"type": "double"
},
"lng": {
"type": "double"
},
"is_fav": {
"type": "boolean"
}
}
},
"Search": {
"required": [
"id",
"api_key",
"params"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"api_key": {
"type": "string"
},
"params": {
"$ref": "#/definitions/SearchParams"
}
}
},
"SearchParams": {
"required": [
"user_id",
"city_id",
"people",
"dt",
"locale"
],
"properties": {
"user_id": {
"type": "string",
"default": "956dda4c21c72e48f5f17a7cd783a0f7"
},
"city_id": {
"type": "string",
"default": "4ec4b3e6098c9d23c925b0c2451eb06a"
},
"people": {
"type": "integer",
"format": "int32",
"minimum": 1,
"default": 2
},
"dt": {
"type": "integer",
"format": "int32",
"default": "1427742000"
},
"locale": {
"type": "string",
"default": "bg"
},
"place_id": {
"type": "string",
"default": "0"
},
"neighborhood_id": {
"type": "string",
"default": "0"
},
"cuisine_id": {
"type": "string",
"default": "0"
},
"kids_place": {
"type": "boolean",
"default": false
},
"price": {
"type": "integer",
"format": "int64",
"default": 1
},
"outdoors": {
"type": "boolean",
"default": false
}
}
},
"Error": {
"required": [
"code",
"data"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"data": {
"type": "array",
"items": {
"type": "array"
}
}
}
}
}
}
However, swagger's validator says it's not valid. The error I get is this
[
{
"level": "error",
"domain": "validation",
"keyword": "anyOf",
"message": "instance failed to match at least one required schema among 2",
"schema": {
"loadingURI": "http://json-schema.org/draft-04/schema#",
"pointer": "/properties/type"
},
"instance": {
"pointer": "/definitions/Place/properties/lat/type"
}
}
]
Note that it works as expected (so far). It displays the data (models and models' structure) properly. Make requests and retrieves responses. Yet the validator says it's not valid. (The yellow badge saying 'Invalid', not the red one that says 'Error').
What am I missing?

Your spec is indeed not valid. In your Place definition, you use "type": "double" to describe the type of the lat (and also lng) property, but such a type does not exist.
If you want to describe a numeric value of 'double' size, you should change the definition as follows:
"lng": {
"type": "number",
"format": "double"
}
Do that everywhere you use the double type, and it should resolve that issue.

Related

Editing json content with azure logic app

I want to create a logic app which replaces the value of resourcename inside an alert json structure received by a logic app. The alarm structure is as follows:
{
"schemaId": "AzureMonitorMetricAlert",
"data": {
"version": "2.0",
"properties": null,
"status": "Deactivated",
"context": {
"timestamp": "2021-08-21T01:43:09.2000007Z",
"id": "/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/microsoft.insights/metricAlerts/teste%20-%20vpnp2s%20count",
"name": "teste - vpnp2s count",
"description": "",
"conditionType": "SingleResourceMultipleMetricCriteria",
"severity": "3",
"condition": {
"windowSize": "PT1M",
"allOf": [
{
"metricName": "P2SConnectionCount",
"metricNamespace": "Microsoft.Network/p2sVpnGateways",
"operator": "GreaterThanOrEqual",
"threshold": "1",
"timeAggregation": "Total",
"dimensions": [],
"metricValue": 0,
"webTestName": null
}
]
},
"subscriptionId": "<subscription_id>",
"resourceGroupName": "<my_resource_group>",
"resourceName": "some_resource_name",
"resourceType": "Microsoft.Network/p2sVpnGateways",
"resourceId": "/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Network/p2sVpnGateways/<p2svpngatewayid>",
"portalLink": "https://portal.azure.com/#resource/subscriptions/<subscription_id>/resourceGroups/<my_resource_group>/providers/Microsoft.Network/p2sVpnGateways/<theresourceid>"
}
}
}
I've been trying all sorts of mix with 'set variable', 'initialize variable', 'compose' blocks, but still no luck. Anyone has a clue?
Based on the above requirement i have created the logic app which replaces the resource name using HTTP request & replace actions.
Below is the code view of my logic app :
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"ConversionToString": {
"inputs": {
"variables": [
{
"name": "StringConversion",
"type": "string",
"value": "#{json(string(triggerBody()))}"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"FInalJsonOutput": {
"inputs": {
"variables": [
{
"name": "JsonOutput",
"type": "object",
"value": "#json(variables('replaceResouceName'))"
}
]
},
"runAfter": {
"ReplaceResourceName": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"ReplaceResourceName": {
"inputs": {
"variables": [
{
"name": "replaceResouceName",
"type": "string",
"value": "#{replace(variables('StringConversion'),'some_resource_name','newresource')}"
}
]
},
"runAfter": {
"ConversionToString": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"data": {
"properties": {
"context": {
"properties": {
"condition": {
"properties": {
"allOf": {
"items": {
"properties": {
"dimensions": {
"type": "array"
},
"metricName": {
"type": "string"
},
"metricNamespace": {
"type": "string"
},
"metricValue": {
"type": "integer"
},
"operator": {
"type": "string"
},
"threshold": {
"type": "string"
},
"timeAggregation": {
"type": "string"
},
"webTestName": {}
},
"required": [
"metricName",
"metricNamespace",
"operator",
"threshold",
"timeAggregation",
"dimensions",
"metricValue",
"webTestName"
],
"type": "object"
},
"type": "array"
},
"windowSize": {
"type": "string"
}
},
"type": "object"
},
"conditionType": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"portalLink": {
"type": "string"
},
"resourceGroupName": {
"type": "string"
},
"resourceId": {
"type": "string"
},
"resourceName": {
"type": "string"
},
"resourceType": {
"type": "string"
},
"severity": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"timestamp": {
"type": "string"
}
},
"type": "object"
},
"properties": {},
"status": {
"type": "string"
},
"version": {
"type": "string"
}
},
"type": "object"
},
"schemaId": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
Here is the sample output for reference post running the above logic app

JSONSchema (draft 7) not validating child definitions for arrays

I'm getting very confused as to why my JSONSchema will not validate my data as expected.
I've appended my JSONShema and Example Date below.
The schema validates the first layer of the nested data structure (the Organisation) without issue, but fails to validate the second layer (User) and below.
Can anybody point me in the right direction as to what I'm doing wrong?
Much appreciated!
JSONSchema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://myorg/json/schemas/report-schedule.json",
"type": "array",
"items": {
"$ref": "#/definitions/Organisation"
},
"definitions": {
"Organisation": {
"type": "object",
"required": [
"organisationId",
"organisationName",
"users"
],
"properties": {
"organisationId": {
"type": "string",
"minLength": 1
},
"organisationName": {
"type": "string",
"minLength": 1
},
"users": {
"type": "array",
"items": {
"ref": "#/definitions/User"
}
}
}
},
"User": {
"type": "object",
"required": [
"name",
"email",
"reports"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"format": "email"
},
"reports": {
"type": "array",
"items": {
"ref": "#/definitions/Report"
}
}
}
},
"Report": {
"type": "object",
"required": [
"reportType",
"reportWeekEndDay",
"sendDay",
"sendHour",
"locations",
"widgets"
],
"properties": {
"reportType": {
"type": "string",
"enum": [
"org-weekly"
]
},
"reportWeekEndDay": {
"type": "integer",
"maximum": 6,
"minimum": 0
},
"sendDay": {
"type": "integer",
"maximum": 6,
"minimum": 0
},
"sendHour": {
"type": "integer",
"maximum": 23,
"minimum": 0
},
"locations": {
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
},
"widgets": {
"$ref": "#/definitions/Widgets"
}
}
},
"Widgets": {
"type": "array",
"title": "Widgets within a report",
"items": {
"$ref": "#/definitions/Widget"
}
},
"Widget": {
"type": "object",
"required": [
"widgetType",
"metrics",
"comparisonType"
],
"properties": {
"widgetType": {
"type": "string",
"enum": [
"table-individual-locations",
"table-all-locations"
]
},
"comparisonType": {
"type": "string",
"enum": [
"week-on-week",
"3-and-1-month-weekly-avg"
]
},
"metrics": {
"$ref": "#/definitions/Metrics"
}
}
},
"Metrics": {
"type": "array",
"title": "The Available Metrics",
"items": {
"oneOf": [
{
"$ref": "#/definitions/FootFallAndMovement"
},
{
"$ref": "#/definitions/Engagement"
},
{
"$ref": "#/definitions/Occupancy"
},
{
"$ref": "#/definitions/SalesDataTransactions"
},
{
"$ref": "#/definitions/SalesDataConversion"
}
]
}
},
"FootFallAndMovement": {
"type": "object",
"required": [
"title",
"type",
"endpoint",
"queryParams"
],
"properties": {
"title": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"const": "FootFallAndMovement"
},
"endpoint": {
"type": "string",
"minLength": 1
},
"queryParams": {
"type": "object",
"required": [
"excludeStaff"
],
"properties": {
"excludeStaff": {
"type": "boolean"
}
}
}
}
},
"Engagement": {
"type": "object",
"required": [
"title",
"type",
"endpoint",
"queryParams"
],
"properties": {
"title": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"const": "Engagement"
},
"endpoint": {
"type": "string",
"minLength": 1
},
"queryParams": {
"type": "object",
"required": [
"excludeStaff",
"contexts"
],
"properties": {
"additionalFilters": {
"type": "object",
"required": [
"ignoreLingerUnder"
],
"properties": {
"ignoreLingerUnder": {
"type": "integer",
"minimum": 1
}
}
},
"excludeStaff": {
"type": "boolean"
},
"contexts": {
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"const": "taxonomy"
},
"value": {
"type": "string",
"minLength": 1
}
}
}
}
}
}
},
"Occupancy": {
"type": "object",
"required": [
"title",
"type",
"endpoint",
"queryParams"
],
"properties": {
"title": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"const": "Occupancy"
},
"endpoint": {
"type": "string",
"minLength": 1
},
"queryParams": {
"type": "object",
"required": [
"excludeStaff",
"contexts"
],
"properties": {
"excludeStaff": {
"type": "boolean"
},
"contexts": {
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"type": "string",
"const": "taxonomy"
},
"value": {
"type": "string",
"minLength": 1
}
}
}
}
}
}
},
"SalesDataTransactions": {
"type": "object",
"required": [
"title",
"type",
"endpoint"
],
"properties": {
"title": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"const": "SalesDataTransactions"
},
"endpoint": {
"type": "string",
"minLength": 1
}
}
},
"SalesDataConversion": {
"type": "object",
"required": [
"title",
"type",
"endpoint",
"queryParams"
],
"properties": {
"title": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"const": "SalesDataConversion"
},
"endpoint": {
"type": "string",
"minLength": 1
},
"queryParams": {
"type": "object",
"required": [
"excludeStaff"
],
"properties": {
"excludeStaff": {
"type": "boolean"
}
}
}
}
}
}
}
Example Data
[
{
"organisationName": "a",
"organisationId": "a",
"users": [
{
"nameWITHERROR": "a"/*e.g. name should be required*/,
"email": "rob#test.com",
"reports": [
{
"reportType": "org-weekly1"/*e.g. this should be an enum*/,
"reportWeekEndDay": 6,
"sendDay": 6,
"sendHour": 6,
"locations": [
"abc",
"bcd"
],
"widgets": [
{
"widgetType": "table-all-locations",
"comparisonType": "3-and-1-month-weekly-avg",
"metrics": [
{
"title": "test",
"type": "FootFallAndMovement1"/*e.g. this enum should fail*/,
"endpoint": "/test",
"queryParams": {
"excludeStaff": true
}
},
{
"title": "test",
"type": "Engagement",
"endpoint": "/test",
"queryParams": {
"excludeStaff": true,
"contexts": {
"type": "taxonomy",
"value": "tests"
}
}
},
{
"title": "test",
"type": "Occupancy",
"endpoint": "/test",
"queryParams": {
"excludeStaff": true,
"contexts": {
"type": "taxonomy",
"value": "tests"
}
}
},
{
"title": "test",
"type": "SalesDataTransactions",
"endpoint": "/test"
},
{
"title": "test",
"type": "SalesDataConversion",
"endpoint": "/test",
"queryParams": {
"excludeStaff": true
}
}
]
}
]
}
]
}
]
}
]
Opening your JSON schema in JSONBuddy shows me immediately that you have used "ref" at /definitions/Organisation/properties/users/items/ref. So there is no validation because the definition is not found.

if-then-else in JSON schema for multiple fields

How can I make few fields as "required" based on condition?
For example; in below case if status==Failed then i want only four fields as required ("orgId",
"subunitId",
"fundOutType",
"status")
but any other value of status will change the required field list: ("transactionId",
"orgId",
"subunitId",
"fundOutType",
"fundOutAmount",
"status")
My below solution is not working. Please help.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"versionId": "1.0",
"javaInterfaces": [
"java.io.Serializable"
],
"type": "object",
"properties": {
"transactionId": {
"type": "string"
},
"orgId": {
"type": "string"
},
"subunitId": {
"type": "string"
},
"fundOutType": {
"type": "string"
},
"fundOutAmount": {
"type": "string"
},
"status": {
"type": "string"
},
"lang": {
"type": "string"
},
"transactionCreatedDateTime": {
"type": "integer",
"format": "date-time"
},
"userId": {
"type": "string"
}
},
"if": {
"properties": {
"status": {
"const": "Failed"
}
},
"required": [ "status" ]
},
"then": {
"required": [
"orgId",
"subunitId",
"fundOutType",
"status"
]
},
"else": {
"required": [
"transactionId",
"orgId",
"subunitId",
"fundOutType",
"fundOutAmount",
"status"
]
}
}
You can use the oneOf clause instead of the if/else:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"versionId": "1.0",
"javaInterfaces": [
"java.io.Serializable"
],
"type": "object",
"properties": {
"transactionId": {
"type": "string"
},
"orgId": {
"type": "string"
},
"subunitId": {
"type": "string"
},
"fundOutType": {
"type": "string"
},
"fundOutAmount": {
"type": "string"
},
"status": {
"type": "string"
},
"lang": {
"type": "string"
},
"transactionCreatedDateTime": {
"type": "integer",
"format": "date-time"
},
"userId": {
"type": "string"
}
},
"oneOf": [
{
"properties": {
"status": {
"const": "Failed"
}
},
"required": [
"orgId",
"subunitId",
"fundOutType",
"status"
]
},
{
"required": [
"transactionId",
"orgId",
"subunitId",
"fundOutType",
"fundOutAmount",
"status"
]
}
]
}
See documentation https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1

Create a recursive json schema which is generic

I am trying to create a json schema for a json file. The structure of the json is generic and I am trying to create a generic schema for json files which contain a similar structure to the one shown below.
**Json file:**
{
"Soccer League": {
"lvl": "Championships",
"state": "1",
"Clubs": {
"Rosely": {
"Boys": {"id": "A1", "state": "Ready"},
"Girls": {
"id": "A2",
"state": "Ready",
"Substitutes": {
"id": "A3",
"state": "Sitting",
"Goalkeepers": {
"Players": {"id": "A4", "state": "Idle"},
"id": "A5",
"state": "Idle",
},
},
},
},
"Division League": {
"TeamA": {
"PlayersA": {
"id": "A6",
"status": "Ready",
"CoachA": {"id": "A7", "state": "Ready"},
},
"PlayersB": {
"id": "A8",
"state": "Playing",
"CoachB": {"id": "A9", "state": "Idle"},
},
}
},
},
}
}
**Json-schema:**
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"Soccer League": {
"type": "object",
"properties": {
"lvl": {
"type": "string"
},
"state": {
"type": "string"
},
"Clubs": {
"type": "object",
"properties": {
"Rosely": {
"type": "object",
"properties": {
"Boys": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"id",
"state"
]
},
"Girls": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"type": "string"
},
"Substitutes": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"type": "string"
},
"Goalkeepers": {
"type": "object",
"properties": {
"Players": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"id",
"state"
]
},
"id": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"Players",
"id",
"state"
]
}
},
"required": [
"id",
"state",
"Goalkeepers"
]
}
},
"required": [
"id",
"state",
"Substitutes"
]
}
},
"required": [
"Boys",
"Girls"
]
},
"Division League": {
"type": "object",
"properties": {
"TeamA": {
"type": "object",
"properties": {
"PlayersA": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"CoachA": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"id",
"status"
]
}
},
"required": [
"id",
"status",
"CoachA"
]
},
"PlayersB": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"CoachB": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"id",
"status"
]
}
},
"required": [
"id",
"status",
"CoachB"
]
}
},
"required": [
"PlayersA",
"PlayersB"
]
}
},
"required": [
"TeamA"
]
}
},
"required": [
"Rosely",
"Division League"
]
}
},
"required": [
"lvl",
"state",
"Clubs"
]
}
},
"required": [
"Soccer League"
]
}
As we can see from above, we have many same layers but just with different names. I am unsure on how to create a recursive json schema for json files which will follow a similar format. This is sort of hard-coded, but how to make it generic.
I am new to json schema and would appreciate if someone could help me infer a schema from the json above. Any help would be greatly appreciated.

Nested objects in JSON response

I am defining my swagger file as below:
{
"swagger": "2.0",
"info": {
"title": "PSD2 Account API Specification",
"description": "PSD2 Account Swagger API Specification",
"version": "1.0.0"
},
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic"
}
},
"security": [
{
"basicAuth": []
}
],
"paths": {
"/accounts/{id}/transactionhistory": {
"get": {
"tags": [
"Accounts"
],
"summary": "Get transaction history",
"operationId": "GetTransactionHistory",
"produces": [
"application/json"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "fromDate",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "toDate",
"in": "query",
"required": false,
"type": "string",
"format": "date"
},
{
"name": "sumOrDetail",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "noOfEntries",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "toTime",
"in": "query",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"$ref": "#/definitions/200TransactionHistory"
}
}
}
}
},
"definitions": {
"200TransactionHistory": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"maxLength": 25
},
"txnCodeDesc": {
"type": "string"
},
"accountDesc": {
"type": "string"
},
"txnCurrency": {
"type": "string",
"maxLength": 3
},
"accountIBAN": {
"type": "string"
},
"valueDate": {
"type": "string",
"format": "date"
},
"transactionCode": {
"type": "object",
"properties": {
"code": {
"type": "string",
"maxLength": 3
},
"subcode": {
"type": "string",
"maxLength": 3
}
}
},
"executionEndTime": {
"type": "string"
},
"stmtEntryId": {
"type": "string",
"maxLength": 90
},
"accountId": {
"type": "string"
},
"transReference": {
"type": "string",
"maxLength": 60
},
"exchangeRate": {
"type": "string",
"maxLength": 11
},
"remittanceInformation": {
"type": "string",
"maxLength": 65
},
"payeeCustomer": {
"type": "string"
},
"closeBalance": {
"type": "string"
},
"bookingDate": {
"type": "string",
"format": "date"
},
"currency": {
"type": "string",
"maxLength": 3
},
"id": {
"type": "string"
},
"txnCurrencyAmount": {
"type": "string",
"maxLength": 25
},
"payeeAccount": {
"type": "string"
},
"openBalance": {
"type": "string"
}
}
}
}
}
There is a simple GET request and I want in the response to have the following format:
"transactionCode": {
"code": "thisIsTheCode",
"SubsubCode": "thisIsTheSubCode"
}
As you can see in the response definition this is how I nest my objects:
"transactionCode": {
"type": "object",
"properties": {
"code": {
"type": "string",
"maxLength": 3
},
"subcode": {
"type": "string",
"maxLength": 3
}
}
}
When I am testing my request from Postman, I am getting the following error message:
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: {"header":{"audit":{"T24_time":107,"parse_time":0},"page_start":0,"page_token":"5fc34084-2496-41f0-a968-084b3b519c88","total_size":0,"page_size":50},"body":}; line: 1, column: 158]
Can anyone tell what I am doing wrong? Is this something wrong in the way I am nesting the objects in the response?