[BUG] [JAVA] wrong values with enum variables in path parameters which generated allowableValues with double quote
Created by: yangguangxiadeyun
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
wrong values with enum variables in path parameters which generated allowableValues with double quote.
I'm expecting path with the path variables to be /dummypath/ACTIVE
or /dummypath/DEACTIVATED
,
but now it generates with allowableValues = "\"ACTIVE\", \"DEACTIVATED\""
and now only /dummypath/"ACTIVE"
and /dummypath/"DEACTIVATED"
available.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: sample
version: v1
servers:
- url: http://localhost
paths:
"/dummypath/{sample-enum-var}":
post:
parameters:
- name: sample-enum-var
in: path
required: true
schema:
$ref: "#/components/schemas/sample-enum-var"
responses:
"200":
description: success
components:
schemas:
sample-enum-var:
type: string
enum:
- ACTIVE
- DEACTIVATED
Command line used for generation
mvn clean package
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-v0</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>sample.yaml</inputSpec>
<generatorName>spring</generatorName>
<modelPackage>com.test.model.v0</modelPackage>
<apiPackage>com.test.api.v0</apiPackage>
<configOptions>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>legacy</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
- setup the maven project with plugin
- run maven command to generate code
- check the code generated in path
target\generated-sources\openapi\src\main\java\com\test\api\v0\DummypathApi.java
sample api interface generated
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (4.3.1).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.test.api.v0;
import com.test.model.v0.SampleEnumVar;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2020-06-24T10:50:17.023+08:00[Asia/Shanghai]")
@Validated
@Api(value = "dummypath", description = "the dummypath API")
public interface DummypathApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
/**
* POST /dummypath/{sample-enum-var}
*
* @param sampleEnumVar (required)
* @return success (status code 200)
*/
@ApiOperation(value = "", nickname = "dummypathSampleEnumVarPost", notes = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "success") })
@RequestMapping(value = "/dummypath/{sample-enum-var}",
method = RequestMethod.POST)
default ResponseEntity<Void> dummypathSampleEnumVarPost(@ApiParam(value = "",required=true, allowableValues = "\"ACTIVE\", \"DEACTIVATED\"") @PathVariable("sample-enum-var") SampleEnumVar sampleEnumVar) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}