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

The response for status "200" already exists for the operation #126

Closed
alcroito opened this issue Mar 25, 2024 · 3 comments
Closed

The response for status "200" already exists for the operation #126

alcroito opened this issue Mar 25, 2024 · 3 comments

Comments

@alcroito
Copy link

Since #88 landed, the example-axum project prints the response for status "200" already exists for the operation when launching the application.

This seems to be due to list_todos_docs trying to override the list_todos route with a 200 response status code, but it already exists.

I discovered this in my own project due having a panic! instead of a println! inside aide::gen::on_error.

Not sure if it's a bug in aide, or the example needs to be modified somehow.

@Wicpar
Copy link
Collaborator

Wicpar commented Mar 25, 2024

It's just an issue with the example. Even if the function is impl IntoApiResponse the response type is automatically derived, but it is also manually added thus the error (which is printed by the on error hook).

@Wicpar Wicpar closed this as completed Mar 25, 2024
@alcroito
Copy link
Author

What if one wants to specify a custom response type for the 200 status code?
Would they have to change the impl IntoApiResponse with a custom type like Json<TodoList> or something, and not specify response::<200, Json<TodoList>>() for the TransformOperation ?

@Wicpar
Copy link
Collaborator

Wicpar commented Mar 25, 2024

The custom response is implicitly generated from the response type, so any Json<MyJsonStruct> will be documented as responding MyJsonStruct with code 200 regardless if if the fn returns Json<MyJsonStruct> or impl IntoApiResponse.

Also consider using axum-jsonschema for the Json response as it gives better json parse errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants