question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] [JAVA] wrong values with enum variables in path parameters which generated allowableValues with double quote

See original GitHub issue

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);

    }

}


Related issues/PRs
Suggest a fix

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

openapi-generator-maven-plugin adds quotes to enumeration ...
So in controller where the generated method is overridden and implemented we specify ... @ApiParam(value = "",required=true, allowableValues ...
Read more >
OpenAPITools - Bountysource
yangguangxiadeyun started a solution on [BUG] [JAVA] wrong values with enum variables in path parameters which generated allowableValues with double quote ($0).
Read more >
Documentation: 15: 8.7. Enumerated Types - PostgreSQL
Enumerated (enum) types are data types that comprise a static, ordered set of values. ... Enum types are created using the CREATE TYPE...
Read more >
An Intermediate MySQL Tutorial - Scripting, Data Types ...
You may provide an absolute or relative path of the filename. You may need to double quote the filename if it contains special...
Read more >
GraphQL specification
Fragments cannot be specified on any input value (scalar, enumeration, ... a string value, a standard quoted string with appropriate escape sequences must ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found