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

Factorizating using allOf does not generate validators #26

Closed
guizmaii opened this issue Aug 1, 2016 · 1 comment
Closed

Factorizating using allOf does not generate validators #26

guizmaii opened this issue Aug 1, 2016 · 1 comment
Assignees

Comments

@guizmaii
Copy link

guizmaii commented Aug 1, 2016

Hi,

It's maybe related to #23, maybe not. I don't know.
Here is the problem.

I have an endpoint:

paths:
  /bars:
    post:
      operationId: postBars
      description: Bar
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/BarsRequest'
      responses:
        200:
          description: Bar OK
          schema:
            $ref: '#/definitions/BarsResponse'

and definitions:

definitions:
  BarsRequest:
    type: object
    properties:
      state:
        type: string
        enum: ["a", "b", "c"]
      id:
        type: string
      query:
        type: string

  BarsResponse:
    type: object
    properties:
      state:
        type: string
        enum: ["a", "b", "c"]
      id:
        type: string
      bars:
        type: array
        items:
          $ref: '#/definitions/Bar'

With these definitions, the generated code is OK.

We can see that state and id are in common to BarsRequest and BarsResponse, so I created AbstractBar and used the allOf keyword:

definitions:

  AbstractBar:
    type: object
    properties:
      state:
        type: string
        enum: ["a", "b", "c"]
      id:
        type: string

  BarsRequest:
    allOf:
      - $ref: '#/definitions/AbstractBar'
      - properties:
          query:
            type: string

  BarsResponse:
    allOf:
      - $ref: '#/definitions/AbstractBar'
      - properties:
          bars:
            type: array
            items:
              $ref: '#/definitions/Bar'

But wIth these new definitions, I have the following error:

capture d ecran 2016-08-01 10 58 06

@slavaschmidt slavaschmidt self-assigned this Oct 24, 2016
@slavaschmidt
Copy link
Collaborator

Fixed in 0.2

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

2 participants