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

Generics produce invalid OpenAPI identifiers #318

Open
Eugeny opened this issue Jul 17, 2022 · 15 comments
Open

Generics produce invalid OpenAPI identifiers #318

Eugeny opened this issue Jul 17, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@Eugeny
Copy link
Contributor

Eugeny commented Jul 17, 2022

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.

@Eugeny Eugeny added the bug Something isn't working label Jul 17, 2022
@sunli829
Copy link
Collaborator

It works fine in Swagger UI/Redoc/Rapidoc, maybe some code generation tools don't recognize it. 🙂

@itsbalamurali
Copy link
Contributor

@sunli829 what's the best workaround? Currently, we use openapi-generator. Getting the same issue as @Eugeny did.

@itsbalamurali
Copy link
Contributor

itsbalamurali commented Jul 22, 2022

@sunli829 can we transform for example PaginatedResponse<SessionSnapshot> to PaginatedResponseOfSessionSnapshot?

@Eugeny
Copy link
Contributor Author

Eugeny commented Jul 22, 2022

Maybe the Object derive macro could also accept an #[oai(generic_name_format="{}<{}>")] and use it to generate the name

@sunli829
Copy link
Collaborator

Maybe the Object derive macro could also accept an #[oai(generic_name_format="{}<{}>")] and use to generate the name

This looks good 🙂

@itsbalamurali
Copy link
Contributor

@Eugeny or @sunli829 any plans on landing this sooner?

@sunli829
Copy link
Collaborator

sunli829 commented Aug 1, 2022

Currently the only solution is to avoid using generics. 🙂

@itsbalamurali
Copy link
Contributor

@Eugeny are you interested in implementing this?

@Eugeny
Copy link
Contributor Author

Eugeny commented Aug 2, 2022

No, I've already worked around it by just modifying the generated JSON schema in my code.

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

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.

@github-actions github-actions bot added the Stale label Sep 2, 2022
@itsbalamurali
Copy link
Contributor

Just pinging to keep the issue alive.

@github-actions github-actions bot removed the Stale label Sep 7, 2022
@itsbalamurali
Copy link
Contributor

@sunli829 Do you have some time to look at this?

@sunli829
Copy link
Collaborator

sunli829 commented Nov 2, 2022

This problem can currently only be solved by avoiding the use of generics. 🙂

@itsbalamurali
Copy link
Contributor

pinging to keep the issue alive.

@balaatsky
Copy link

ping again :)

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

4 participants