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 API spec for actual route definition #394

Closed
juhaku opened this issue Dec 7, 2022 Discussed in #355 · 2 comments · Fixed by #1004
Closed

Use API spec for actual route definition #394

juhaku opened this issue Dec 7, 2022 Discussed in #355 · 2 comments · Fixed by #1004
Labels
enhancement New feature or request

Comments

@juhaku
Copy link
Owner

juhaku commented Dec 7, 2022

Discussed in #355

Originally posted by TitanNano November 19, 2022
We started to build our public API with axum and utoipa and are already facing the issue that we discover miss matches between the API spec and the actual implementation in axum.

Examples for this are, route path does not match utoipa path or method does not match utoipa path. For this reason, I started looking into what is being generated for the OpenAPI spec and how we could use that to avoid the drift between implementation and documentation.
What I found is quite nice, we can access the entire APS spec and extract all paths and methods from it to build our router. I discovered only two issues that block us from doing this, though:

  1. there is no way of getting from the API spec to the correct handler function for axum. There is the operation id which by default matches the handler function name and with some macro magic, I might be able to locate the correct function, but I do not want to expose such an implementation detail in our public API spec. We would be depending on the operation id always matching the function name.
  2. We are currently using route layer extensions to inject dependencies into our route handlers, and we will need some way of associating them with the path definition.
@juhaku
Copy link
Owner Author

juhaku commented Mar 22, 2023

Related #537

@juhaku
Copy link
Owner Author

juhaku commented Aug 16, 2024

There is now coming up implementation for this to reduce the duplicate endpoint registration. Currently in experimenting phase #991

@juhaku juhaku moved this to In Progress in utoipa kanban Aug 26, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

1 participant