Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Swagger validation: 'items' inside schema objects should be strictly optional. #245

Closed
IvanGoncharov opened this issue Jul 12, 2015 · 7 comments

Comments

@IvanGoncharov
Copy link
Contributor

This exception is triggered when Schema object is missing 'items'.

But Swagger spec, enforce presence of 'items' only in schema-like objects like for e.g parameters.
But for Schema objects it borrow rules from Draft4, see:
https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#schema-object
http://json-schema.org/latest/json-schema-validation.html#anchor130

@whitlockjc
Copy link
Member

/cc @webron

@webron
Copy link

webron commented Jul 12, 2015

That's a misinterpretation of the spec. If type: array, items is always required.

@IvanGoncharov
Copy link
Contributor Author

@webron Here it said:

Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here.

And I don't see any requirements for items inside Schema object.
But JSON Schema treat items as optional field.

Should I submit issue in swagger-spec repository?
If it intended to be mandatory why don't JSON Schema for Swagger documents doesn't enforce this?
Using dependencies validation for JSON Schema.

@webron
Copy link

webron commented Jul 13, 2015

Sure, you can submit a ticket on swagger-spec for clarification.

The JSON Schema is for the spec is not 100% compliant, and it never will be (mostly due to limitations with JSON Schema, but also due to complexity and maintenance issues). In any case, the JSON Schema is not the source of truth but the spec is.

@IvanGoncharov
Copy link
Contributor Author

The JSON Schema is for the spec is not 100% compliant

We discuss it already many times. And this issue is not about JSON Schema compatibility,
there is OAI/OpenAPI-Specification/issues/333 for that. Instead I want to follow 2.0 spec
as much as possible and for doing that I need validator tool and specification in sync.

This discussion became unrelated to swagger-tool so I opened OAI/OpenAPI-Specification/issues/404

@webron
Copy link

webron commented Jul 13, 2015

OAI/OpenAPI-Specification#333 is definitely unrelated. I was talking about the JSON Schema for the spec as a whole. OAI/OpenAPI-Specification#333 refers to e possible expansion of definition in a future version of the spec.

@IvanGoncharov
Copy link
Contributor Author

It should be clarify in Swagger spec itself.
So I close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants