Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail reference resolving with array type without items property #2074

Closed
MugeSo opened this issue Apr 5, 2016 · 10 comments
Closed

Fail reference resolving with array type without items property #2074

MugeSo opened this issue Apr 5, 2016 · 10 comments

Comments

@MugeSo
Copy link
Contributor

MugeSo commented Apr 5, 2016

swagger-ui version: 2.1.4

{
  "swagger": "2.0",

  "basePath": "/api",

  "info": {
    "title": "sample",
    "version": "1.0.0"
  },

  "paths": {
    "/foo": {
      "get": {
        "description": "Foo",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "A list of pets.",
            "schema": {
              "type": "array"
            }
          }
        }
      }
    }
  }
}

For example, schema definition for json-schema its self has this.

@fehguy
Copy link
Contributor

fehguy commented Apr 5, 2016

It's not supported. Per the specification, items is required under an array, see the docs.

@fehguy fehguy closed this as completed Apr 5, 2016
@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 5, 2016

@fehguy How about this:

{
  "swagger": "2.0",

  "basePath": "/api",

  "info": {
    "title": "sample",
    "version": "1.0.0"
  },

  "paths": {
    "/foo": {
      "get": {
        "description": "Foo",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "A list of pets.",
            "schema": { "$ref": "http://json-schema.org/schema#"  }
          }
        }
      }
    }
  }
}

@fehguy
Copy link
Contributor

fehguy commented Apr 5, 2016

I don't know what you mean--I do suggest reading the specification so you can understand what is possible.

@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 5, 2016

I got it.

@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 5, 2016

@fehguy Please teach me where is the description that items is required in Schema Object.
I can find description about items required in Header Object and Parameter Object but I can't for Schema Object

@ponelat
Copy link
Member

ponelat commented Apr 5, 2016

@MugeSo the swagger spec, is based on JSON-Schema, in the Schema Object you'll note a reference to items which is gets from JSON-Schema.

However, that said. Its a simple property, and you use this description as a reference... https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#itemsObject

@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 5, 2016

@ponelat Thanks, I understand items in Items Object is required when type is array.
There is still no description items property of Schema Object.
However I found it is just a omission in spec.

I disappointed found that we can not reference many of existing json schema...

Thanks a lot.

@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 5, 2016

@MugeSo
Copy link
Contributor Author

MugeSo commented Apr 6, 2016

@fehguy @ponelat
I read spec carefully.
And I feel sure items of Schema Object is optional for now.

@ponelat refers Item Object but it is not for schema in body and response.

A limited subset of JSON-Schema's items object. It is used by parameter definitions that are not located in "body".

@webron
Copy link
Contributor

webron commented Apr 6, 2016

@MugeSo - as someone who was involved in writing the spec, I can tell you the intent - items is mandatory no matter where you declare the type to be an array. We can go back and forth on this, but it won't change.

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

No branches or pull requests

4 participants