-
Notifications
You must be signed in to change notification settings - Fork 112
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
Name collision on request/response objects #16
Comments
Additionally, I should note that there are two possible areas to fix:
I suppose another option to fixing this would be to provide some form of I suppose it depends on what would produce the most idiomatic OpenAPI sheet. |
Here is the JSON for reference: {
"openapi": "3.0.0",
"info": {
"title": "",
"version": ""
},
"servers": [
{
"url": "/my_resource"
}
],
"paths": {
"/one": {
"get": {
"operationId": "handler_one_handler_one",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Response"
}
}
}
}
}
}
},
"/two": {
"get": {
"operationId": "handler_two_handler_two",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Response"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Response": {
"type": "object",
"required": [
"reply"
],
"properties": {
"reply": {
"type": "string"
}
}
}
}
}
} |
So this is really a shortcoming of schemars, where schemas are given a name which gets appended to This can currently be worked around by adding a pub mod handler_two {
use super::*;
#[derive(serde::Serialize, schemars::JsonSchema)]
#[schemars(rename = "Response2")] // <-- add this attribute!
pub struct Response {
different_schema: String,
}
... It may be possible to improve this in schemars by including the output of |
When two routes have the same name for a Request / Response the namespaces are clobbered. Example:
https://github.com/leeola/example_okapi_name_collision (specifically this file) will incorrectly report that the
/two
route has a response type of:Instead of what it should be,
I'm happy to help developing a solution to this, but I'm unsure how best it can be handled. Ideally, I imagine something resembling idiomatic OpenAPI specs should be generated. Though, looking at the classic PetStore example it looks like that entire bottom area is ripe for having many structure names occupy the same namespace.
Thoughts on how best to handle this?
The text was updated successfully, but these errors were encountered: