[Java] Default values for string-type query parameters are generated with two sets of quotes
Created by: OmriHarary
Description
In annotations on parameters for generated api methods, default values for request query parameters are surrounded in two sets of double quotes. Completely prevents compilation.
Example of problem code, generated using information below:
@ApiOperation(value = "", nickname = "fooGet", notes = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/foo",
method = RequestMethod.GET)
default ResponseEntity<Void> fooGet(@ApiParam(value = "", defaultValue = ""foobar"") @Valid @RequestParam(value = "bar", required = false, defaultValue=""foobar"") String bar) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Example partial result from running mvn package
on generated project:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project openapi-spring: Compilation failure: Compilation failure:
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,80] ')' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,86] <identifier> expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,88] ';' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,159] ')' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,165] <identifier> expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,167] ';' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,179] = expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,181] illegal start of type
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[43,182] <identifier> expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,16] = expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,19] ';' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,35] <identifier> expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,36] illegal start of type
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,37] '(' expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,47] illegal start of type
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[44,63] = expected
[ERROR] /path/to/src/main/java/org/openapitools/api/FooApi.java:[48,1] class, interface, or enum expected
openapi-generator version
latest master
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Issue example
version: 1.0.0
paths:
/foo:
get:
parameters:
- name: bar
in: query
required: false
schema:
type: string
default: foobar
responses:
default:
description: successful operation
Command line used for generation
java -jar openapi-generator-cli.jar generate -g spring -i openapi.yaml