Comments (4)
#318 and #670 are about similar problems.
#671 implemented a solution for the generics problem, but sadly got no feedback so far.
The current output is non-compliant with the OpenAPI spec, even if SwaggerUI & Co don't complain:
All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9.-_]+$
(https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#components-object)
The problem I see with both your suggestion (Prefix with ListOf
instead of wrapping in brackets) as well as the one in #671 (replace special characters with underscore) is that it might collide with non-generics that use the same name - but IMHO both solutions would be preferable to just not be able to use Generics at all without generating invalid OpenAPI specs.
@sunli829 would you be open to a PR that removes the disallowed characters, and if so, do you have a preference for the format (i.e., replace punctuation with underscores, Prefix with a String like "Of", ...)?
from poem.
Currently it is not possible to customize the OpenAPI name corresponding to a generic type. If you need a legal name, you can only avoid using generics.
from poem.
I have a proposition,
why not take the template ( [{}] ) directly from a global variable, which can be modified?
fn name() -> Cow<'static, str> {
format!("[{}]", T::name()).into()
}
to
fn name() -> Cow<'static, str> {
format!(get_vec_gen_template(), T::name()).into()
}
from poem.
Hello,
@amtelekom if we make the template dynamic so that each developer can customize it only for their needs
I think @sunli829 is so busy lately, it would be nice if he assigned a moderator to help him.
from poem.
Related Issues (20)
- Misuse of span.record in tracing middleware HOT 2
- Dependency hell: poem fails to build when `hyper-util 0.1.1` is selected
- Union doesn't support generics in the last version HOT 1
- Union doesn't implement `IsObjectType` HOT 1
- Add CookieConfig to Csrf middleware
- static files performance is weird. Does I missing something?
- Acme-alpn does not work
- Multiple 200 OK options?
- Add Typed Multipart Data Extractor to Poem
- Moving from `serde_json` to faster json parser lib
- Transform errors when extract parameters HOT 1
- poem-lambdaV5.0.0 AWS API Gateway triggering lambda is not supported?
- poem-openapi 5.0.1 is incompatible with poem-openapi-derive 5.0.0 HOT 1
- Allow SecurityScheme as Macro parameter of OpenApi or oai
- Middleware examples are out of date
- EmbeddedFilesEndpoint not working for index.html in subdirectory HOT 2
- [poem-openapi] Path parameters in `prefix_path` do not generate the correct openapi specification HOT 1
- Redirect response type error HOT 1
- RequestId Middleware display ERROR Message
- The api doc request response 502 when set the host `0.0.0.0` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poem.