-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
The generated openapi scheme for union has changed. Is it possible to restore the previous schema? #263
Comments
The default is poem/poem-openapi/tests/union.rs Line 374 in 008679d
|
This has not changed anything.
This specification is still being generated:
|
@sunli829 Maybe it is better to generate the enum specification this in way ?
|
Since each object in the union doesn't actually have a |
This is a swaggerUI error. I understand that you have good intentions. But the result is a strange contract. |
can you expand on how discriminator is defined ? If you add explicit mapping to structures, that's already cool for me.
|
OK, I'll update later. 😁 |
Swagger ui doesn't show https://github.com/poem-web/poem/tree/rework-openapi-union
|
I would like to advise you but I am having trouble getting this new version to work: In the test repository I switched to this new branch:
|
|
Sorry, I fixed this now. 😂 |
Yes, it is much better now :) Only now there is another problem. The "discriminator" is missing one of the types:
|
I suggest that It is better to generate a model for each of the generics.
|
Thanks for the suggestion, I will try it tomorrow. 🙂 |
@sunli829 Do you want the "type" field to necessarily be shown by swaggerUI ? |
@sunli829 Hello. Will you be publishing these changes ? Even what is now on the branch unfinished works well. I use these changes in production :) |
In |
Cool. I missed the moment that you released version 2.0.0-alpha.1 :) I will try this version in my project |
@sunli829 - Hello. Would it be possible for you to add this mapping fix ? |
Sorry for the late reply, in fact I still don't know how to fix it. @szagi3891 |
The changes you made in the branch rework-openapi-union fix my problem. maybe you will use this solution method ? |
Fixed in |
Sure, I'll be happy to help :)
"discriminator" and "mapping" looks very good. Is it possible to remove this intermediate structure "CreateSessionResponse[CreateSessionResponseOk]" ? |
It cannot be deleted because the |
Information about this additional type, is provided by this structure:
It seems that swagger ui has a bug and cannot correctly visualise the type specified in the discriminator. redoc, on the other hand, is good at visualising the discriminator |
This should not be Swagger's bug, as the example provided in the spec, every object should contain the components:
schemas:
Pet:
type: object
required:
- petType
properties: # <<<----------------------- add the petType property
petType:
type: string
discriminator:
propertyName: petType
mapping:
dog: Dog
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
properties:
name:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: string
Lizard:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Lizard`
properties:
lovesRocks:
type: boolean |
You are right. https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
It looks like your change is working very well :) |
Do you know this solution? Perhaps it is worth applying to poem ? |
I know, I just want all the work to be done by myself, which is more controllable. 😂 |
I understand :) Do you support such enums ? |
It is not supported yet, I will add it later. 🙂 |
The OpenAPI specification doesn't support this, do you really need it? |
Not necessary. But from what I've heard, there's a better alternative to discriminator. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
This issue was closed because it has been stalled for 5 days with no activity. |
Previously the union scheme was generated like this:
After recently updating the poem in the project to the latest version, I noticed that it generates like this:
Is it possible to restore the previous specification format ? The previous version was much better
The text was updated successfully, but these errors were encountered: