poem
poem copied to clipboard
Generics produce invalid OpenAPI identifiers
Having a generic type with #[derive(Object)]
will produce identifiers like PaginatedResponse<SessionSnapshot>
which look nice, but are not valid according to the spec:
Component names can only contain the characters A-Z a-z 0-9 - . _
It would be nicer to allow renaming them at the specialization site with an [oai(rename)]
, or allow forcing the definition to be inlined in the spec.
It works fine in Swagger UI
/Redoc
/Rapidoc
, maybe some code generation tools don't recognize it. 🙂
@sunli829 what's the best workaround? Currently, we use openapi-generator. Getting the same issue as @Eugeny did.
@sunli829 can we transform for example PaginatedResponse<SessionSnapshot>
to PaginatedResponseOfSessionSnapshot
?
Maybe the Object derive macro could also accept an #[oai(generic_name_format="{}<{}>")]
and use it to generate the name
Maybe the Object derive macro could also accept an
#[oai(generic_name_format="{}<{}>")]
and use to generate the name
This looks good 🙂
@Eugeny or @sunli829 any plans on landing this sooner?
Currently the only solution is to avoid using generics. 🙂
@Eugeny are you interested in implementing this?
No, I've already worked around it by just modifying the generated JSON schema in my code.
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.
Just pinging to keep the issue alive.
@sunli829 Do you have some time to look at this?
This problem can currently only be solved by avoiding the use of generics. 🙂
pinging to keep the issue alive.
ping again :)