Description
Generate code with an enum string path param and the generated spring-mvc code will not compile due to the way the generated enum values are quoted
Failing generated code - note the quoted values inside the allowableValues quote:
public ResponseEntity<Void> demoGet(@ApiParam(value = "day of the week",required=true, allowableValues="{values=[Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday], enumVars=[{name=MONDAY, value="Monday"}, {name=TUESDAY, value="Tuesday"}, {name=WEDNESDAY, value="Wednesday"}, {name=THURSDAY, value="Thursday"}, {name=FRIDAY, value="Friday"}, {name=SATURDAY, value="Saturday"}, {name=SUNDAY, value="Sunday"}]}" ) @PathVariable("day") String day) { // do some magic! return new ResponseEntity<Void>(HttpStatus.OK); }
Swagger-codegen version
2.2.2-SNAPSHOT (master) - tried also with 2.2.1
Swagger declaration file content or url
Sample failing yaml
#YAML Demonstration
swagger: '2.0'
info:
title: Demonstration of Swagger Yaml with Enumeration
description: Simple Demonstration of Enumeration
version: "1.0.0"
host: api.bastide.org
schemes:
- https
basePath: /1/{day}
produces:
- application/atom+xml
paths:
/demo:
get:
summary: demonstration for enumeration
description: |
Demonstrates an enumeration
parameters:
- name: day
in: path
description: day of the week
required: true
type: string
enum:
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
responses:
200:
description: The response upon succesful query
default:
description: Error occured
If you switch back to query param type the generated code is fine.
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./test.yaml -l spring -o samples/server/example/spring-mvc
Steps to reproduce
Use the sample yaml above saved as test.yml.
Run the code gen command line above
cd to samples/server/example/spring-mvc
run mvn compile
Look at the DemoApiController.java to see the issue.
Related issues
Similar area to #4550 perhaps?
Suggest a Fix
Will update if I can work something out
Description
Generate code with an enum string path param and the generated spring-mvc code will not compile due to the way the generated enum values are quoted
Failing generated code - note the quoted values inside the allowableValues quote:
public ResponseEntity<Void> demoGet(@ApiParam(value = "day of the week",required=true, allowableValues="{values=[Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday], enumVars=[{name=MONDAY, value="Monday"}, {name=TUESDAY, value="Tuesday"}, {name=WEDNESDAY, value="Wednesday"}, {name=THURSDAY, value="Thursday"}, {name=FRIDAY, value="Friday"}, {name=SATURDAY, value="Saturday"}, {name=SUNDAY, value="Sunday"}]}" ) @PathVariable("day") String day) { // do some magic! return new ResponseEntity<Void>(HttpStatus.OK); }Swagger-codegen version
2.2.2-SNAPSHOT (master) - tried also with 2.2.1
Swagger declaration file content or url
Sample failing yaml
If you switch back to query param type the generated code is fine.
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./test.yaml -l spring -o samples/server/example/spring-mvcSteps to reproduce
Use the sample yaml above saved as test.yml.
Run the code gen command line above
cd to samples/server/example/spring-mvc
run mvn compile
Look at the DemoApiController.java to see the issue.
Related issues
Similar area to #4550 perhaps?
Suggest a Fix
Will update if I can work something out