question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger 2.0 validation loop

See original GitHub issue

Hi there,

I’m trying to build an sbt task to validate my swagger.json document against the 2.0 spec using fge/json-schema-validator

When I try to validate this example the validation fails with a validation loop error.

Here is an explanation by fge: https://groups.google.com/forum/#!msg/json-schema/UyM06JItXKQ/sS3PO6cWoK8J

If I’m not mistaken, there may be a significant flaw with the 2.0 spec (I haven’t checked 1.2)

This is how fge/json-schema-validator reports the error:

[error] com.github.fge.jsonschema.core.exceptions.ProcessingException: fatal: validation loop: schema "http://swagger.io/v2/schema.json#/definitions/primitivesItems/properties/type" visited twice for pointer "/paths/~1pets/get/parameters/0/items/type" of validated instance
[error]     level: "fatal"
[error]     schema: {"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/primitivesItems/properties/type"}
[error]     instance: {"pointer":"/paths/~1pets/get/parameters/0/items/type"}
[error]     domain: "validation"
[error]     alreadyVisited: "http://swagger.io/v2/schema.json#/definitions/primitivesItems/properties/type"
[error]     instancePointer: "/paths/~1pets/get/parameters/0/items/type"
[error]     validationPath: ["#","#/properties/basePath","#/properties/consumes","http://swagger.io/v2/schema.json#/definitions/mediaTypeList/items","#/properties/definitions","http://swagger.io/v2/schema.json#/definitions/definitions/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/format","http://swagger.io/v2/schema.json#/definitions/schema/properties/type","http://json-schema.org/draft-04/schema#/properties/type/anyOf/0","http://json-schema.org/draft-04/schema#/properties/type/anyOf/1","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/type","http://json-schema.org/draft-04/schema#/properties/type/anyOf/0","http://json-schema.org/draft-04/schema#/properties/type/anyOf/1","http://swagger.io/v2/schema.json#/definitions/schema/properties/required","http://json-schema.org/draft-04/schema#/definitions/stringArray/items","http://json-schema.org/draft-04/schema#/definitions/stringArray/items","http://swagger.io/v2/schema.json#/definitions/definitions/additionalProperties","http://swagger.io/v2/schema.json#/definitions/definitions/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/format","http://swagger.io/v2/schema.json#/definitions/schema/properties/type","http://json-schema.org/draft-04/schema#/properties/type/anyOf/0","http://json-schema.org/draft-04/schema#/properties/type/anyOf/1","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/type","http://json-schema.org/draft-04/schema#/properties/type/anyOf/0","http://json-schema.org/draft-04/schema#/properties/type/anyOf/1","http://swagger.io/v2/schema.json#/definitions/schema/properties/properties/additionalProperties","http://swagger.io/v2/schema.json#/definitions/schema/properties/type","http://json-schema.org/draft-04/schema#/properties/type/anyOf/0","http://json-schema.org/draft-04/schema#/properties/type/anyOf/1","http://swagger.io/v2/schema.json#/definitions/schema/properties/required","http://json-schema.org/draft-04/schema#/definitions/stringArray/items","http://json-schema.org/draft-04/schema#/definitions/stringArray/items","#/properties/host","#/properties/info","http://swagger.io/v2/schema.json#/definitions/info/properties/contact","http://swagger.io/v2/schema.json#/definitions/contact/properties/email","http://swagger.io/v2/schema.json#/definitions/contact/properties/name","http://swagger.io/v2/schema.json#/definitions/contact/properties/url","http://swagger.io/v2/schema.json#/definitions/info/properties/description","http://swagger.io/v2/schema.json#/definitions/info/properties/license","http://swagger.io/v2/schema.json#/definitions/license/properties/name","http://swagger.io/v2/schema.json#/definitions/license/properties/url","http://swagger.io/v2/schema.json#/definitions/info/properties/termsOfService","http://swagger.io/v2/schema.json#/definitions/info/properties/title","http://swagger.io/v2/schema.json#/definitions/info/properties/version","#/properties/paths","http://swagger.io/v2/schema.json#/definitions/paths/patternProperties/%5E~1","http://swagger.io/v2/schema.json#/definitions/pathItem/properties/get","http://swagger.io/v2/schema.json#/definitions/operation/properties/description","http://swagger.io/v2/schema.json#/definitions/operation/properties/operationId","http://swagger.io/v2/schema.json#/definitions/operation/properties/parameters","http://swagger.io/v2/schema.json#/definitions/parametersList/items","http://swagger.io/v2/schema.json#/definitions/parametersList/items/oneOf/0","http://swagger.io/v2/schema.json#/definitions/parameter/oneOf/0","http://swagger.io/v2/schema.json#/definitions/bodyParameter/properties/description","http://swagger.io/v2/schema.json#/definitions/bodyParameter/properties/in","http://swagger.io/v2/schema.json#/definitions/bodyParameter/properties/name","http://swagger.io/v2/schema.json#/definitions/bodyParameter/properties/required","http://swagger.io/v2/schema.json#/definitions/parameter/oneOf/1","http://swagger.io/v2/schema.json#/definitions/nonBodyParameter/oneOf/0","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/collectionFormat","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/description","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/in","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/items","http://swagger.io/v2/schema.json#/definitions/primitivesItems/properties/type","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/name","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/required","http://swagger.io/v2/schema.json#/definitions/headerParameterSubSchema/properties/type","http://swagger.io/v2/schema.json#/definitions/nonBodyParameter/oneOf/1","http://swagger.io/v2/schema.json#/definitions/formDataParameterSubSchema/properties/collectionFormat","http://swagger.io/v2/schema.json#/definitions/formDataParameterSubSchema/properties/description","http://swagger.io/v2/schema.json#/definitions/formDataParameterSubSchema/properties/in","http://swagger.io/v2/schema.json#/definitions/formDataParameterSubSchema/properties/items"]

Thoughts?

UPDATE Seems that the schema has a circular dependency: nonBodyParameter -> queryParameterSubSchema -> properties -> items -> primitivesItems -> items -> primitivesItems -> items -> primitiveItems ...

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fgecommented, Oct 29, 2014

The aforementioned issue is now fixed in version 2.2.6 (just published).

0reactions
luisobocommented, Oct 29, 2014

Woah, that’s great. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation Loop error occurred when allOf used with ...
Hello,. I've been implementing request validation by using OpenApiInteractionValidator for a schema with inheritance.
Read more >
swagger 2.0 not validating enum in header - Stack Overflow
I am working on a project that uses Swagger 2.0 to generate an API interface which is then implemented in production code.
Read more >
OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. These files can then be used by the Swagger-UI project...
Read more >
validating request and response against swagger - Forums - IBM
This will help us validate the request in entry point itself instead of moving further flow. We can ignore the request if failed...
Read more >
Fix Swagger Validator errors in Power Platform connectors
SchemaRefLoopNotAllowed, The schema definition may not use a '$ref' to point to another definition. There is a reference loop in your schema (A ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found