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

Use to_resource_type in PolymorphicAutoSchema #14

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

Use to_resource_type in PolymorphicAutoSchema #14

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

Comments

@ADR-007
Copy link

ADR-007 commented Mar 26, 2020

Hi!

Pls, change this:

'mapping': {c.name: c.ref['$ref'] for c in sub_components},

to:

serializer_model_mapping = {value: key for key, value in serializer.model_serializer_mapping.items()}

        return {
            'oneOf': [c.ref for c in sub_components],
            'discriminator': {
                'propertyName': serializer.resource_type_field_name,
                'mapping': {
                    serializer.to_resource_type(serializer_model_mapping[sub_components[0].object]): c.ref['$ref'] 
                    for c in subcomponents
                },
            }
        }
@tfranzel tfranzel added the bug Something isn't working label Mar 26, 2020
@tfranzel
Copy link
Owner

Hi, i think that should address your problem. your snipped had the right idea but was incomplete.

please reopen if that does not solve your problem. cheers.

@ADR-007
Copy link
Author

ADR-007 commented Mar 27, 2020

Thanks!

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

2 participants