JoeScho / oas2joi

Create a Joi schema from an Open API Specification
11 stars 2 forks source link

allOf only supports $ref as the first element #2

Closed simontabor closed 5 years ago

simontabor commented 5 years ago

Offending line is here: https://github.com/JoeScho/oas2joi/blob/master/index.js#L27

Should this be changed to loop over all items in allOf?

Test case:

components:
  schemas:
    ThingWithId:
      allOf:
        - type: object
          required:
            - id
          properties:
            id:
              type: string
              format: uuid
              description: I am a UUID
        - $ref: '#/components/schemas/ThingWithoutId'

    ThingWithoutId:
      required:
        - status
      properties:
        status:
          type: boolean
          description: Some random status thing
JoeScho commented 5 years ago

Hey @simontabor 👋

Thanks for raising this!