Skip to content

Missing required property definition while using allOf with requried and properties #1212

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

Closed
jeremycohensolal opened this issue Mar 10, 2017 · 9 comments

Comments

@jeremycohensolal
Copy link

Swagger File

---
  swagger: "2.0"
  info: 
    version: "1.0.0"
    title: "test API"
    description: "Handle all internals requests to back-office."

  host: "test.api.com"
  basePath: "/v2"
  schemes: 
    - "https"
  consumes: 
    - "application/json"
  produces: 
    - "application/json"

  paths:
    /foo:
      post: 
        summary: "Create a foo"
        parameters:
          - 
            name: "bar"
            in: "body"
            required: true
            schema: 
              allOf: 
                - 
                  required: 
                    - "req1"
                    - "req2"
                    - "req3"
                    - "req4"
                - 
                  properties: 
                    req1:
                      type: "string"
                      format: "uuid"
                - 
                  $ref: "#/definitions/Foo"

        responses: 
          201: 
            description: "The created foo"

  definitions:
    Foo:
      type: "object"
      properties: 
        req2:
          type: "string"

        req3:
          type: "string"

        req4:
          type: "string"

        opt1:
          type: "string"

        opt2:
          type: "string"
  • Version: 51.0.1 (32 bits)
  • Browser/OS: Firefox

Issue

Using this YAML file throw these errors

swag

Other validating tools are ok...

term

@gbangban
Copy link

Running into the same issue here.

@fehguy
Copy link
Contributor

fehguy commented Apr 19, 2017

Looks great on the 3.x editor version:

https://editor.swagger.io/

image

@gbangban
Copy link

gbangban commented Apr 20, 2017

The 3.0 editor is great, but there's still widespread use of the 2.0 editor and UI.

I ended up pulling the properties out of the array. I.e.

              - properties: 
                  req1:
                    type: "string"
                    format: "uuid"

to

                properties: 
                  req1:
                    type: "string"
                    format: "uuid"

That will fix the parsing for the req1 property, but it will not fix the rest of the properties of the parent model. I'm not sure if the spec supports that level of composition, but you can pull those requirements down to the implementing model for a working spec.

Grazie for the quick response.

@fehguy
Copy link
Contributor

fehguy commented Apr 20, 2017

Hi, as we have limited resources, our efforts are focused on the new version, which will allow us to support the next specification. If someone can create a PR for the 2.x series, with tests, we can certainly get it in.

@gbangban
Copy link

Good on my end.

I appreciate all the work you folks are doing!

@jeremycohensolal
Copy link
Author

This issue makes me wonder, what is the validation library used in swagger editor?

I test some complex swagger files with

  • swagger-client
  • swagger-tools
  • swagger editor

and these 3 tools don't spot the same validation errors...

@webron
Copy link
Contributor

webron commented Apr 24, 2017

@nemenemsrouge the editor uses its own validation mechanism. It's a combination of JSON Schema validation and manual validations.

@jeremycohensolal
Copy link
Author

Thx @webron. Good point to know...

It would be nice to have a exhaustive validation library (for CI or things like like this)
Existent libraries are all behaving differently...

Maybe sharing the validation system as a small standalone project could be a good idea?

@webron
Copy link
Contributor

webron commented Apr 25, 2017

At the moment we have no plans on extracting the validation as a standalone library.

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

No branches or pull requests

4 participants