Parser is throwing error for a valid OpenAPI File
See original GitHub issueThe attached content is valid but the parser is throwing error " attribute components.schemas.Vehicle.enum is not of type value
"
{
"openapi": "3.0.0",
"servers": [{
"description": "Production environment",
"url": "https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry"
},
{
"description": "Test environment",
"url": "https://uat.driver-vehicle-licensing.api.gov.uk/vehicle-enquiry"
}
],
"info": {
"contact": {
"email": "DvlaAPIAccess@dvla.gov.uk",
"name": "DVLA API Team",
"x-twitter": "GDSTeam"
},
"description": "Interface specification for the DVLA Vehicle Enquiry API",
"title": "Vehicle Enquiry",
"version": "1.1.0",
"x-apisguru-categories": [
"open_data"
],
"x-logo": {
"url": "https://api.apis.guru/v2/cache/logo/https_twitter.com_GDSTeam_profile_image.png"
},
"x-origin": [{
"format": "openapi",
"url": "https://developer-portal.driver-vehicle-licensing.api.gov.uk/apis/vehicle-enquiry-service/v1.1.0-vehicle-enquiry-service.json",
"version": "3.0"
}],
"x-preferred": true,
"x-providerName": "api.gov.uk",
"x-serviceName": "vehicle-enquiry"
},
"tags": [{
"name": "vehicle"
}],
"paths": {
"/v1/vehicles": {
"post": {
"description": "Returns vehicle details based on registration number",
"operationId": "getVehicleDetailsByRegistrationNumber",
"parameters": [{
"description": "Client Specific API Key",
"in": "header",
"name": "x-api-key",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "Consumer Correlation ID",
"in": "header",
"name": "X-Correlation-Id",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Vehicle"
}
}
},
"description": "Registration number of the vehicle to find details for",
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Successful response"
},
"400": {
"description": "Bad Request"
}
},
"summary": "Get vehicle details by registration number",
"tags": [
"vehicle"
]
}
}
},
"components": {
"schemas": {
"ErrorResponse": {
"description": "Error Response",
"properties": {
"errors": {
"items": {
"$ref": "#/components/schemas/Errors"
},
"type": "array"
}
},
"type": "object"
},
"Errors": {
"properties": {
"code": {
"description": "DVLA reference code",
"example": "105",
"type": "string"
},
"detail": {
"description": "A meaningful description of the error which has occurred",
"example": "Invalid format for field - vehicle registration number",
"type": "string"
},
"status": {
"example": "400",
"type": "string"
},
"title": {
"description": "Error title",
"example": "Invalid vrn number",
"type": "string"
}
},
"required": [
"title"
],
"type": "object"
},"obj1": {
"type": "object",
"properties": {
"stringVar": {
"type": "string",
"format": "myFormat"
},
"dateVar": {
"type": "string",
"format": "date"
}
},
"xml": {
"name": "objName",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
}
},
"objA": {
"type": "object",
"properties": {
"stringVar": {
"type": "string",
"format": "myFormat"
},
"dateVar": {
"type": "string",
"format": "date"
}
}
},
"Vehicle": {
"required": [
"arrayB",
"arrayF",
"arrayI",
"strVar",
"ObjectRootArr"
],
"properties": {
"arrayA":
{
"type":"array",
"items":{
}
},
"arrayB":
{
"type":"array",
"items":{
"description": "int64 with all true",
"example": "20",
"format": "int64",
"type": "integer",
"minimum": 10,
"maximum": 50,
"nullable": true,
"exclusiveMinimum": true,
"exclusiveMaximum": true,
"multipleOf": 10,
"readOnly": true,
"title":"exist"
}
},
"arrayC":
{
"type":"array",
"items":{
"example": "20",
"format": "int32",
"type": "integer",
"minimum": 10,
"maximum": 50,
"nullable": true,
"exclusiveMinimum": true,
"exclusiveMaximum": true,
"multipleOf": 10,
"writeOnly": true,
"title":"exist",
"enum":
[1,2]
}
} ,
"arrayD":
{
"type":"array",
"items":{
"example": "20",
"format": "float",
"type": "number",
"minimum": 10.23,
"maximum": 50.23,
"nullable": true,
"exclusiveMinimum": true,
"exclusiveMaximum": true,
"multipleOf": 10,
"writeOnly": true,
"title":"exist",
"enum":
[10.2,5.3],
"default":10.2
}
} ,
"arrayE":
{
"type":"array",
"items":{
"description": "MOT Status of the vehicle",
"enum": [
"No details held by DVLA",
"No results returned",
"Not valid",
"/"
],
"example": "No details held by DVLA",
"type": "string",
"nullable": false,
"minLength": 12,
"maxLength": 20,
"default": "/"
}
} ,
"arrayF":
{
"type":"array",
"items":{
"description": "MOT Status of the vehicle",
"enum": [
"2017-07-21T17:32:28Z",
"2017-07-12T17:32:28Z"
],
"example": "No details held by DVLA",
"type": "string",
"format":"date-time",
"nullable": false,
"minLength": 12,
"maxLength": 20,
"default": "2017-07-12T17:32:28Z"
}
}
,
"arrayG":
{
"type":"array",
"items":{
"type":"array",
"items":{
"type":"integer",
"format":"int32",
"minimum":12,
"maximum":24,
"nullable":true,
"exclusiveMinimum": true,
"exclusiveMaximum": true,
"enum":[ 1,2],
"default":1
},
"enum":[[ 1,2],[ 11,22]]
}
}
,
"arrayH":
{
"type":"array",
"items":{
"type":"array",
"items":{
"type":"string",
"nullable":true,
"enum":[ "1", "2" ]
},
"enum":[ ["1", "2"],["3", "2"] ]
}
},
"arrayI":
{
"type":"array",
"items":{
"type":"object",
"properties":{
"id":
{
"type":"string",
"nullable":true,
"enum":[ "1", "2" ]
},
"sal":
{
"type":"integer",
"format":"int64",
"nullable":true,
"minimum":12
}
}
}
}
,
"strVar": {
"type": "array",
"minItems": 30,
"maxItems": 200,
"uniqueItems": true,
"xml": {
"name": "Strings",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": true,
"wrapped": true
},
"items": {
"type": "string",
"format": "myFormat",
"minLength": 3,
"maxLength": 20,
"pattern": "myPattern",
"title": "myTitle",
"description": "myDesc",
"default": "A",
"nullable": true,
"readOnly": false,
"writeOnly": true,
"enum": [
"A",
"B"
],
"xml": {
"name": "myString",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": true
},
"deprecated": true,
"externalDocs": {
"url": "http://abc.com",
"description": "my description"
},
"x-var1": "myVar",
"x-var2": {
"var3": "val3",
"var4": "val4"
}
}
},
"dateVar": {
"type": "array",
"minItems": 30,
"maxItems": 200,
"uniqueItems": false,
"xml": {
"name": "Dates",
"namespace": "http://abc1.com",
"prefix": "ns1",
"attribute": false,
"wrapped": false
},
"items": {
"type": "string",
"format": "date"
}
} ,
"PrimitiveRootArr": {
"type": "array",
"minItems": 30,
"maxItems": 200,
"uniqueItems": true,
"xml": {
"name": "Strings",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": true,
"wrapped": true
},
"items": {
"type": "string"
}
},
"ObjectArr": {
"type": "object",
"properties": {
"obj": {
"type": "array",
"minItems": 30,
"maxItems": 200,
"uniqueItems": true,
"xml": {
"name": "Objects",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
},
"items": {
"type": "object",
"xml": {
"name": "objOne",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
},
"properties": {
"var1": {
"type": "string"
},
"var2": {
"type": "integer"
}
}
}
}
}
},
"ObjectRootArr": {
"type": "array",
"minItems": 30,
"maxItems": 200,
"uniqueItems": true,
"xml": {
"name": "Objects",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
},
"items": {
"type": "object",
"xml": {
"name": "objOne",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": true,
"wrapped": true
},
"properties": {
"var1": {
"type": "string"
},
"var2": {
"type": "integer"
}
}
}
},
"obj1": {
"type": "object",
"properties": {
"stringVar": {
"type": "string",
"format": "myFormat"
},
"dateVar": {
"type": "string",
"format": "date"
}
},
"xml": {
"name": "objName",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
}
},
"obj2": {
"type": "object",
"properties": {
"var1": {
"type": "string"
},
"var2": {
"type": "array",
"minItems": 20,
"maxItems": 200,
"uniqueItems": true,
"items": {
"$ref": "#/components/schemas/obj1"
},
"xml": {
"name": "Var2s",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
}
}
}
},
"obj3": {
"type": "array",
"minItems": 30,
"maxItems": 300,
"uniqueItems": true,
"items": {
"$ref": "#/components/schemas/obj1"
},
"xml": {
"name": "Var2s",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
}
},
"objNested1": {
"type": "array",
"minItems": 10,
"maxItems": 100,
"uniqueItems": true,
"items": {
"$ref": "#/components/schemas/obj1"
},
"xml": {
"name": "Var2s",
"namespace": "http://abc.com",
"prefix": "ns",
"attribute": false,
"wrapped": true
}
},
"arrayJ":
{
"type":"array",
"items":{
"oneOf":
[
{ "type":"number","format":"float"},
{ "type":"integer","format":"int32"}
]
}
},
"obj2refoneof": {
"type": "object",
"properties": {
"var1": {
"type": "string"
},
"var2": {
"type": "array",
"minItems": 20,
"maxItems": 200,
"uniqueItems": true,
"items": {
"oneOf":[
{"$ref": "#/components/schemas/obj1"},
{"$ref": "#/components/schemas/objA"}
]
}
}
}
}
},
"type": "object"
}
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Azure API Manager OpenApiSpecification parser claims errors ...
I have an OpenAPI hooked up to my Azure API manager. I have a valid OpenAPI json file that was generated by my...
Read more >Error importing valid OpenApi example · Issue #294 - GitHub
Go 'Add new Api'; Select OpenAPI type; Import attached OpenAPI file; Parsing errors are displayed: Parsing error(s): Data and type mismatch ...
Read more >Parsing error(s): The input OpenAPI file is not valid for the ...
When we are validating the schema with OpenAPI specification getting the below error . One or more fields contain incorrect values: Parsing ......
Read more >Swagger 2.0 and OpenAPI 3.0 parser/validator - API Dev Tools
Parses Swagger specs in JSON or YAML format · Validates against the Swagger 2.0 schema or OpenAPI 3.0 Schema · Resolves all $ref...
Read more >DAST OpenAPI attempts to parse non OpenAPI specifications
DeserializationUtils - Error snake-parsing yaml content ... plugin checks to see if a file is an OpenAPI specification file, and if it is, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On the other hand, for the
enum
values of anarray
orobject
schema, a better solution might be to store the correspondingJsonNode
objects. This provides parser clients with a well-documented API for accessing the parsed contents of eachenum
value. And this doesn’t require any new dependency for parser clients.Hi @gracekarina @kerrykimbrough @sullis @anicolas Thanks for all your contributions, with the latest fix I see that the issue I reported is fixed. Much appreciate the help.
Regards, Sree