Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

$ref with other fields #16

Closed
ADR-007 opened this issue Mar 27, 2020 · 2 comments
Closed

$ref with other fields #16

ADR-007 opened this issue Mar 27, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ADR-007
Copy link

ADR-007 commented Mar 27, 2020

Hi!

Currenlty it doesn't work (the "readonly" is ignored):
image

Fix:
Change this:

return {'$ref': f'#/components/{self.type}/{self.name}'}

to:

        return {'allOf': [{'$ref': f'#/components/{self.type}/{self.name}'}]}

Result (inheritance with overriding):
image

(it doesn't look like the correct way to fix it. so, it is just example)

@ADR-007
Copy link
Author

ADR-007 commented Mar 27, 2020

my workaround:

    def _map_serializer_field(self, method, field):
        field = super()._map_serializer_field(method, field)

        if '$ref' in field:
            all_of = field.setdefault('allOf', [])
            all_of.append({'$ref': field.pop('$ref')})

        return field

@tfranzel tfranzel added the bug Something isn't working label Mar 27, 2020
@tfranzel
Copy link
Owner

tfranzel commented Mar 27, 2020

that was a good catch. the spec is not 100% clear, if that actually behaves as intended. at least its more valid than before 😁 Also SwaggerUI properly recognizes it so that should be good enough here.

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

No branches or pull requests

2 participants