Debezium MySql source connector - cant see data in topic - mysql

I have defined Debezium MySQL source connector with the following configuraion
{
"name": "quickstart-debezium-source1",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"tasks.max": 1,
"database.hostname": "host.docker.internal",
"database.server.name": "connect_test",
"database.server.id": "5555",
"database.port": "3306",
"database.user": "root",
"database.password": "Fintech1!",
"database.history.kafka.topic": "debezium-source",
"database.history.kafka.bootstrap.servers": "broker:29092",
"include.schema.changes": "true",
"key.converter" : "io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url" : "http://host.docker.internal:8081",
"value.converter":"io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url": "http://host.docker.internal:8081",
"topic.creation.default.replication.factor": -1,
"topic.creation.default.partitions": -1,
"topic.creation.default.cleanup.policy": "compact",
"topic.creation.default.compression.type": "lz4"
Also have the following table in MySql:
I am able to see in Kafka new topic created and also new data that being added/updated to the table.
but, I can't see the new data on the topic (I am using confluent-cloud-center)
On the topic I can see the new data like:
I cant see the values of the columns in the table
Also I am trying to create a KSQLDB table out of this topic and no results are coming.
Hope some1 could help me with that,
I also have schema-registry, and the schema registry of the topic is:
{
"type": "record",
"name": "Envelope",
"namespace": "connect_test.connect_test.test",
"fields": [
{
"name": "before",
"type": [
"null",
{
"type": "record",
"name": "Value",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "name",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "email",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "department",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "modified",
"type": {
"type": "string",
"connect.version": 1,
"connect.default": "1970-01-01T00:00:00Z",
"connect.name": "io.debezium.time.ZonedTimestamp"
},
"default": "1970-01-01T00:00:00Z"
}
],
"connect.name": "connect_test.connect_test.test.Value"
}
],
"default": null
},
{
"name": "after",
"type": [
"null",
"Value"
],
"default": null
},
{
"name": "source",
"type": {
"type": "record",
"name": "Source",
"namespace": "io.debezium.connector.mysql",
"fields": [
{
"name": "version",
"type": "string"
},
{
"name": "connector",
"type": "string"
},
{
"name": "name",
"type": "string"
},
{
"name": "ts_ms",
"type": "long"
},
{
"name": "snapshot",
"type": [
{
"type": "string",
"connect.version": 1,
"connect.parameters": {
"allowed": "true,last,false,incremental"
},
"connect.default": "false",
"connect.name": "io.debezium.data.Enum"
},
"null"
],
"default": "false"
},
{
"name": "db",
"type": "string"
},
{
"name": "sequence",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "table",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "server_id",
"type": "long"
},
{
"name": "gtid",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "file",
"type": "string"
},
{
"name": "pos",
"type": "long"
},
{
"name": "row",
"type": "int"
},
{
"name": "thread",
"type": [
"null",
"long"
],
"default": null
},
{
"name": "query",
"type": [
"null",
"string"
],
"default": null
}
],
"connect.name": "io.debezium.connector.mysql.Source"
}
},
{
"name": "op",
"type": "string"
},
{
"name": "ts_ms",
"type": [
"null",
"long"
],
"default": null
},
{
"name": "transaction",
"type": [
"null",
{
"type": "record",
"name": "ConnectDefault",
"namespace": "io.confluent.connect.avro",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "total_order",
"type": "long"
},
{
"name": "data_collection_order",
"type": "long"
}
]
}
],
"default": null
}
],
"connect.name": "connect_test.connect_test.test.Envelope"
}

Related

How to use Parser Transformation for JSON data in IICS?

I am new to IICS and I have JSON data as below, which I would to parse in csv file. I am using this link as a reference to achieve this transformation. I created valid mapping in IICS.The mapping runs fine. However, when I see my jobs I am receiving below error.I went to the path mentioned and opened the Events.cme file in Notepad but cannot make of what file is talking about (Note: in belwo output I deleted few of the numbers)
Not sure what is wrong ? Do I need to save my JSON data file as txt file ?
Any help will be appreciated! Thanks in advance!
ERROR after running the mapping
[ERROR] Failed to process data: File C:/IICSLabFiles/test.json doesn't exist or isn't readable- for more information see file://C:/PROGRA~1/Informatica Cloud Secure Agent/apps/Data_Integration_Server/data/CMReports/Tmp/2022-06-01/HierarchyParser_h2r_udt_8gns3_ONLY_H2R_XMAP_/Events.cme
Opening Events.cme file in notepad produces following
<B#80010%#>
!~109146~165266~~10.2.2.65()
<B#80032%#>
</B#8032%#>
<m -- XMap%m>
!~103149~1654220266~~Pages\/page_m_1.cmv%Pages\/page_m_1.json
<B#80037%XML#>
!~1031~1654220266~~Pages\/Input_of_m_1.cmv%Pages\/Input_of_m_1.json
<LocalFile>
!~309025~16542266~~C:\/IICSLabFiles\/test.json
</LocalFile>
!~103205~16540266~~C:\/IICSLabFiles\/test.json
!~3033~1654220266~~
</B#8007%XML#>
</m -- XMap>
</B#80010%#>
JSON Data that is saved in test.json (with File type as JSON File):
{
"current_page": 1,
"first_page_url": "https://covid-api.com/api/regions?per_page=20&page=1",
"last_page_url": "https://covid-api.com/api/regions?per_page=20&page=50",
"next_page_url": "https://covid-api.com/api/regions?per_page=20&page=2",
"prev_page_url": null,
"per_page": "20",
"last_page": 50,
"from": 1,
"path": "https://covid-api.com/api/regions",
"to": 20,
"total": 997,
"data": [
{
"iso": "CHN",
"name": "China"
},
{
"iso": "TWN",
"name": "Taipei and environs"
},
{
"iso": "USA",
"name": "US"
},
{
"iso": "JPN",
"name": "Japan"
},
{
"iso": "THA",
"name": "Thailand"
},
{
"iso": "KOR",
"name": "Korea, South"
},
{
"iso": "SGP",
"name": "Singapore"
},
{
"iso": "PHL",
"name": "Philippines"
},
{
"iso": "MYS",
"name": "Malaysia"
},
{
"iso": "VNM",
"name": "Vietnam"
},
{
"iso": "AUS",
"name": "Australia"
},
{
"iso": "MEX",
"name": "Mexico"
},
{
"iso": "BRA",
"name": "Brazil"
},
{
"iso": "COL",
"name": "Colombia"
},
{
"iso": "FRA",
"name": "France"
},
{
"iso": "NPL",
"name": "Nepal"
},
{
"iso": "CAN",
"name": "Canada"
},
{
"iso": "KHM",
"name": "Cambodia"
},
{
"iso": "LKA",
"name": "Sri Lanka"
},
{
"iso": "CIV",
"name": "Cote d'Ivoire"
}
]
}
**JSON SCHEMA that is saved in Hierarchy schema (with file type as JSON FILE) **
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"current_page": {
"type": "integer"
},
"first_page_url": {
"type": "string"
},
"last_page_url": {
"type": "string"
},
"next_page_url": {
"type": "string"
},
"prev_page_url": {
"type": "null"
},
"per_page": {
"type": "string"
},
"last_page": {
"type": "integer"
},
"from": {
"type": "integer"
},
"path": {
"type": "string"
},
"to": {
"type": "integer"
},
"total": {
"type": "integer"
},
"data": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
},
{
"type": "object",
"properties": {
"iso": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"iso",
"name"
]
}
]
}
},
"required": [
"current_page",
"first_page_url",
"last_page_url",
"next_page_url",
"prev_page_url",
"per_page",
"last_page",
"from",
"path",
"to",
"total",
"data"
]
}
Source connection Setup
Path_text file contains following information
Path
C:/IICSLabFiles/test.json
The error message "C:/IICSLabFiles/test.json doesn't exist or isn't readable" suggests you try reading local file. Is this the path to the file located on Secure Agent running the mapping or is it the path to a file stored on your laptop? What is your Source definition?
Keep in mind that you design the mapping on your laptop where you have access to files stored on your laptop - but once you execute, it gets processed by Secure Agent (that can be a different machine, cloud-hosted, etc.). In this case it seems the Secure Agent cannot access the file at the given location.
It's also possible to have Secure Agent installed on your machine and run the process on the laptop where you actually have been designing the mapping. In such case please make sure there are no typos in the path, no leading or trailing empty spaces. And if it's a Windows-based Secure Agent, verify the paths as the one you use has froward slashes while Windows uses backslashes usually:
C:/IICSLabFiles/test.json
vs
C:\IICSLabFiles\test.json

How to parse a dynamic Json - Power Automate

Im getting a http response from Azure LogAnalytics, the response is a Json like this
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "TimeGenerated",
"type": "datetime"
},
{
"name": "DestinationIP",
"type": "string"
},
{
"name": "DestinationUserName",
"type": "string"
},
{
"name": "country_name",
"type": "string"
},
{
"name": "country_iso_code",
"type": "string"
},
{
"name": "AccountCustomEntity",
"type": "string"
}
],
"rows": [
[
"2021-05-17T14:07:01.878Z",
"158.000.000.33",
"luis",
"United States",
"US",
"luis"
]
]
}
]
}
I will never get the same colums or sometimes i will get more rows with data like this
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "Account",
"type": "string"
},
{
"name": "Computer",
"type": "string"
},
{
"name": "IpAddress",
"type": "string"
},
{
"name": "AccountType",
"type": "string"
},
{
"name": "Activity",
"type": "string"
},
{
"name": "LogonTypeName",
"type": "string"
},
{
"name": "ProcessName",
"type": "string"
},
{
"name": "StartTimeUtc",
"type": "datetime"
},
{
"name": "EndTimeUtc",
"type": "datetime"
},
{
"name": "ConnectinCount",
"type": "long"
},
{
"name": "timestamp",
"type": "datetime"
},
{
"name": "AccountCustomEntity",
"type": "string"
},
{
"name": "HostCustomEntity",
"type": "string"
},
{
"name": "IPCustomEntity",
"type": "string"
}
],
"rows": [
[
"abc\\abc",
"EQ-DC02.abc.LOCAL",
"0.0.0.0",
"User",
"4624 - An account was successfully logged on.",
"10 - RemoteInteractive",
"C:\\Windows\\System32\\svchost.exe",
"2021-05-17T15:02:25.457Z",
"2021-05-17T15:02:25.457Z",
2,
"2021-05-17T15:02:25.457Z",
"abc\\abc",
"EQ-DC02.abc.LOCAL",
"0.0.0.0"
],
[
"abc\\eona",
"EQPD-SW01.abc.LOCAL",
"0.0.0.0",
"User",
"4624 - An account was successfully logged on.",
"10 - RemoteInteractive",
"C:\\Windows\\System32\\svchost.exe",
"2021-05-17T15:21:45.993Z",
"2021-05-17T15:21:45.993Z",
1,
"2021-05-17T15:21:45.993Z",
"abc\\abc",
"EQPD-SW01.abc.LOCAL",
"0.0.0.0"
]
]
}
]
}
Im using Power Automate to parse this kind of Json to a Object or to make a response
the question is, how can i parse this "Columns" and "Rows" to a object?
Similar discussion happened in community forum and the solution identified was:
parse JSON and transform it to XML and then search keys with XPATH in Flow

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?

JSON Schema Draft-07 if-then-else required field validation does not seem correct

Using Draft-07
What I got was
valid JSON
What error I expected from audit object was
directory: String length must be greater than or equal to 2
Tried two different validators with same results
https://www.jsonschemavalidator.net/
GoLang https://github.com/xeipuuv/gojsonschema
This is my schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ISAM-Wrapper",
"description": "Validate isam wrapper json",
"type": "object",
"properties": {
"directory": {
"description": "path to location of isam file",
"type": "string",
"minLength": 2
},
"isamFile": {
"description": "isam database file",
"type": "string",
"minLength": 4
},
"isamIndex": {
"description": "isam index file",
"type": "string",
"minLength": 4
},
"port": {
"description": "port number for REST listener",
"type": "integer",
"minimum": 60410,
"maximum": 69999
},
"actions": {
"description": "Which operations are supported",
"type": "object",
"items": {
"properties": {
"create": {
"type": "boolean"
},
"read": {
"type": "boolean"
},
"update": {
"type": "boolean"
},
"delete": {
"type": "boolean"
}
}
},
"required": [
"create",
"read",
"update",
"delete"
]
},
"fields": {
"description": "each object describes one field of the isam file",
"type": "array",
"minItems": 1,
"items": {
"title": "field",
"description": "field schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"ordinal": {
"type": "integer",
"minimum": 0
},
"offset": {
"type": "integer",
"minimum": 0
},
"length": {
"type": "integer",
"minimum": 1
},
"dataType": {
"enum": [
"uchar",
"ulong",
"long",
"uint",
"int",
"ushort",
"short"
]
}
},
"required": [
"name",
"ordinal",
"offset",
"length",
"dataType"
]
}
},
"audit": {
"description": "input needed to enable and configure isam auditing",
"type": "object",
"items": {
"properties": {
"enable": {
"enum": [
true,
false
]
},
"directory": {
"type": "string",
"minLength": 2
},
"fileName": {
"type": "string",
"minLength": 4
},
"workDirectory": {
"type": "string",
"minLength": 2
},
"archiveDirectory": {
"type": "string",
"minLength": 2
},
"interval": {
"type": "integer",
"minimum": 1
},
"byteThreshold": {
"type": "integer",
"minimum": 1048576,
"maximum": 1073741824
}
}
},
"required": [
"enable"
],
"if": {
"not": {
"properties": {
"enable": {
"enum": [
false
]
}
}
}
},
"then": {
"required": [
"directory",
"fileName",
"workDirectory",
"archiveDirectory",
"interval",
"byteThreshold"
]
}
}
},
"required": [
"directory",
"isamFile",
"isamIndex",
"port",
"actions",
"fields",
"audit"
]
}
This is my JSON
{
"directory": "./",
"isamFile": "isam.dat",
"isamIndex": "isam.idx",
"port": 60410,
"actions": {
"create": true,
"read": true,
"update": true,
"delete": true
},
"fields": [
{
"name": "F1",
"ordinal": 0,
"offset": 0,
"length": 4,
"dataType": "ulong"
},
{
"name": "F2",
"ordinal": 1,
"offset": 4,
"length": 4,
"dataType": "ulong"
}
],
"audit": {
"enable": true,
"directory": "",
"fileName": "file",
"workDirectory": "./work",
"archiveDirectory": "./archive",
"interval": 5,
"byteThreshold": 1500000
}
}
This issue you have is that your schema is invalid. For both actions and audit you specify these as objects but you don't provide any properties. What you do do, however, is specify an items key (which does nothing here - that's a key on an array) which contains the properties.
Once you correct this error, the schema behaves as you intend, see https://repl.it/repls/BlankWellmadeFrontpage

Swagger - Invalid JSON errors

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.