Re-usable enums in path/query parameters
See original GitHub issueI’ve been told that it’s not possible to use schemas in path/query parameters, but I have a case where multiple paths use the same enum pattern for inputs.
For example, I have the following pattern that is duplicated over many paths:
parameters:
- in: "query"
...
enum:
- id
- sku
- guid
- stock
...
Is it possible to generalize this in some way, so that I don’t have to define them for each path, but can just reference them?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:22
- Comments:27 (16 by maintainers)
Top Results From Across the Web
Swagger: Reusing an enum definition as query parameter
I'm defining the Swagger Enum in the definitions part of my Swagger 2.0 spec file. OperationType: type: string enum: - registration - renewal....
Read more >Enums - Swagger
Reusable enums. In OpenAPI 3.0, both operation parameters and data models use a schema , making it easy to reuse the data types....
Read more >Unsupported REST Enum Use Cases - OutSystems 11 ...
Use cases currently unsupported when consuming REST services using "enums" and how to overcome some of these situations.
Read more >[MockMvc] [OpenAPI 3.0] Type of enum parameter not picked ...
Declare an endpoint with a (path or query) parameter that refers to an enum from components section. For example, take a look at...
Read more >F.A.Q - Springdoc-openapi
@Bean public GroupedOpenApi storeOpenApi() { String paths[] = {"/store/**"}; return ... How can I add Reusable Enums ?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chanthakim15 Here is a quick example
@BigstickCarpet’s example is correct. If any of swagger tools is not supporting it, it’s a bug. Please file a bug for it.
Flip the order, all good
EDIT: Some more info: Using a local copy of the Swagger Editor. Did reproduce with http://editor.swagger.io/#/ as well, quickly