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

Add inheritance support #5

Open
tomaspavlin opened this issue Feb 19, 2021 · 1 comment
Open

Add inheritance support #5

tomaspavlin opened this issue Feb 19, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@tomaspavlin
Copy link

Parsing swagger with allOf does not work properly.

The following model defined in swagger.yaml

    RecipientModelToUpdate:
        allOf:
        -   $ref: '#/definitions/PatientModelToUpdate'
        -   properties:
                acceptable_blood_groups:
                    description: Provide full list of all the acceptable blood groups
                        of the patient, not just the change set
                    items:
                        $ref: '#/definitions/BloodGroupEnum'
                    type: array
                acceptable_blood_groups2:
                    description: Provide full list of all the acceptable blood groups
                        of the patient, not just the change set
                    example:
                    - A
                    - B
                    items:
                        $ref: '#/definitions/BloodGroupEnum'
                    type: array
                cutoff:
                    type: integer
                hla_antibodies:
                    allOf:
                    -   $ref: '#/definitions/HlaAntibodiesToUpdate'
                    description: Provide full list of all the HLA antibodies of the
                        patient, not just the change set
                    example:
                        hla_antibodies_list:
                        -   mfi: 10000
                            raw_code: A*01:02
                hla_types_list_test:
                    items:
                        $ref: '#/definitions/HlaTypeToUpdate'
                    type: array
                previous_transplants:
                    description: Number of previous kidney transplants.
                    type: integer
                recipient_requirements:
                    allOf:
                    -   $ref: '#/definitions/RecipientRequirements'
                    description: Provide the whole recipients requirements object,
                        it will be overwritten
                    example:
                        require_better_match_in_compatibility_index: true
                waiting_since:
                    description: Date since when the patient has been on waiting list.
                        Use format YYYY-MM-DD.
                    example: '2015-01-17'
                    format: date
                    type: string
            required:
            - hla_types_list_test
            type: object

was parsed using

swagger_parser = SwaggerParser(swagger_yaml_path, use_example=True)

with unexpected results in swagger_parser.definitions_example.RecipientModelToUpdate:

image

Most of the defined fields are missing.

@tomaspavlin
Copy link
Author

When I implemented swagger validation, I also got the following error:

jsonschema.exceptions.ValidationError: 'A' is not of type 'array'

Failed validating 'type' in schema['allOf'][1]['properties']['acceptable_blood_groups']:
    {'description': '...',
     'example': ['A', '0'],
     'items': {'$ref': '#/definitions/BloodGroupEnum'},
     'type': 'array'}

On instance['acceptable_blood_groups']:
    'A'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant