Skip to content

allOf element's required keyword is ignored, if its element doesn't have properites keyword #77

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
grktsh opened this issue Aug 16, 2018 · 0 comments
Labels
area/schema Indicates an issue on schema area kind/bug/confirmed

Comments

@grktsh
Copy link
Contributor

grktsh commented Aug 16, 2018

I'd like to define PetNew schema for POST /pets and PetUpdate schema for PATCH /pets/{pet_id} as following to reuse name schema:

components:
  schemas:
    PetNew:
      allOf:
      - $ref: '#/components/schemas/PetUpdate'
      - type: object
        required:
        - name
    PetUpdate:
      type: object
      properties:
        name:
          type: string

But openapi-core treats PetNew's name property as optional.

def test_all_of_required_keyword_only_element(self):
    schema = Schema('object', all_of=[
        Schema('object', properties={'name': Schema('string')}),
        Schema('object', required=['name']),
    ])
    assert schema.get_all_required_properties_names() == {'name'}

swagger-editor shows no schema errors for this definitions and openapi-generator generates required name property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Indicates an issue on schema area kind/bug/confirmed
Projects
None yet
Development

No branches or pull requests

2 participants