Open Zstorm999 opened 5 months ago
So I found the problem at this line: https://github.com/poem-web/poem/blob/83413facbe4e0c4e8d4e2c72dbc8ca23361e6dd9/poem-openapi-derive/src/api.rs#L197
When the full path is generated below, no conversion is applied to the prefix_path, only to the oai_path. This means the path is half-standardized in the final output.
So I searched a bit for this problem. There is indeed no generated oai path for the prefix_path
attribute. However, due to this line:
The prefix_path
can actually be a variable, and not just a string literal. This makes it impossible to validate that path unless a breaking change is introduced requirering it to be a string literal just like the regular path
.
There is already a test for this case:
Hello !
I have an api specification of the form :
Note that I have path parameters in both
prefix_path
andpath
.Expected Behavior
I expect the parameter
name
to be included in the api spec, so the generated spec should be something likeActual Behavior
Instead, what is being generated is
This causes problems with api viewers (tested with redoc and swagger-ui), as they do not generate the correct request.
Expected:
Actual
Additional testing
For the record, I tested the following api construction in Rust:
This generates the correct specification, but poem is then unable to correctly use the route and I get a 404 error when trying to access it.
Specifications
Full code example
```rust use poem::{listener::TcpListener, Route, Server}; use poem_openapi::{param::{Path, Query}, payload::PlainText, OpenApi, OpenApiService}; struct Api; #[OpenApi(prefix_path="/hello/:name")] impl Api { #[oai(path = "/:surname", method = "get")] async fn index(&self, name: Path