Apis that return a generic type (Foo<T>) where T is an ENUM overrides APIs that return a T that is a String
See original GitHub issueHi
An issue appears to exist with Enum’s and generic types where if we have two APIs that return:
ResponseWrapper<String>
ResponseWrapper<MyEnum
Then I find that the generated swagger json contains:
"ResponseWrapper«string»": {
"properties": {
"data": {
"allowEmptyValue": false,
"description": "...",
"enum": [
"FOO",
"BAR"
],
"type": "string"
},
"errorMessage": {
"allowEmptyValue": false,
"description": "If a error occurs a user friendly message may be placed here.",
"type": "string"
}
},
"title": "ResponseWrapper«string»",
"type": "object"
}
So now swagger thinks that for anything that returns a ResponseWrapper<String>
it is restricted to the values of the enum. This is particularly problematic when a client is generated from the JSON. As ResponseWrapper<String>
is made to return a ResponseWrapper<MyEnum>
instead.
I appear to be depending on:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.19</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Java enum implements interface with Class<T> return type
Here's an enum that implements an interface with a method that returns a 'raw type' which gives me a warning on the getCaste()...
Read more >Extensions — The Swift Programming Language (Swift 5.7)
An extension can be used to extend an existing generic type, as described in Extending a Generic Type. You can also extend a...
Read more >Monkey C Language Reference - Garmin Developers
The goal of Monkey C is to round the sharp edges of app development, ... types must be declared for each function parameter...
Read more >Avro C - Apache Avro
Most functions in the Avro C library return a single int status code. ... the C types used to represent Avro data in...
Read more >Sensor | Android Developers
A constant string describing an accelerometer sensor type. ... Returns true if the sensor supports sensor additional information API.
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 Free
Top 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
A fix for this would be highly appreciated! Thank you!
I worked around the problem by extending my class e.g.
the down side is each person needs to remember to actually do that.