-
Notifications
You must be signed in to change notification settings - Fork 222
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
Dynamic discriminator #3590
Comments
Hi @dotjpg3141
What's missing from your description is the mapping property under the discriminator object as described in the specification. Let us know if you have further questions. |
The value of the discriminator changes based on the base URL of the server. If I generate the client based on a Swagger document on body:
oneof:
- $ref: '#/components/schemas/FooResponse'
- $ref: '#/components/schemas/BarResponse'
discriminator:
propertyName: odata.metadata
mapping:
https://a.example.com/v1.0/$metadata#foo: FooResponse
https://a.example.com/v1.0/$metadata#bar: BarResponse If I deploy this client to body:
oneof:
- $ref: '#/components/schemas/FooResponse'
- $ref: '#/components/schemas/BarResponse'
discriminator:
propertyName: odata.metadata
mapping:
https://b.example.com/v1.0/$metadata#foo: FooResponse
https://b.example.com/v1.0/$metadata#bar: BarResponse |
Thanks for the additional information. |
Exactly
Interesting to know. I'll have to check the Microsoft OData examples. My current implementation returns an absolute path. |
To answer your initial question, dynamic discriminators are not supported today. And I don't think we'll ever support them. This would require the factory of models to call into consumer provided code.
|
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
I have an OData Endpoint that handles batch operations via
/$batch
. To differentiate between responses, the discriminatorodata.metadata
can be used. Unfortunately, this discriminator is tied to the API's base URL and varies depending on that URL. How can we handle a dynamic discriminator?Schema
Example Request
Example Response
The text was updated successfully, but these errors were encountered: