Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #7506
Closed
Open
Issue created Sep 24, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [SPRING] Generator do not respect reserved words mappings for FormParams

Created by: ahrytsiuk

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

There is an error in mustache template file modules/openapi-generator/src/main/resources/JavaSpring/formParams.mustache that causes a compilation error if you use a reserved keyword as the name of a form parameter - baseName is using instead of paramName

openapi-generator version

4.3.1 (latest stable release)

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Example
  description: Example
  version: 1.0.0

paths:
  /example/api:
    post:
      summary: summary
      operationId: description
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                super:
                  type: string
                  format: binary
                package:
                  type: string
                  format: binary
      responses:
        200:
          description: response
Generation Details
    @ApiOperation(value = "summary", nickname = "description", notes = "", tags={  })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "response") })
    @PostMapping(
        value = "/example/api",
        consumes = { "multipart/form-data" }
    )
    default ResponseEntity<Void> description(@ApiParam(value = "") @Valid @RequestPart(value = "super", required = false) MultipartFile super,@ApiParam(value = "") @Valid @RequestPart(value = "package", required = false) MultipartFile package) {
        return getDelegate().description(_super, _package);
    }

Which leads to a completion error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project open-api-reserved-words-mappings: Compilation failure: Compilation failure: 
[ERROR] .../api/ExampleApi.java:[48,110] <identifier> expected
[ERROR] .../api/ExampleApi.java:[48,191] <identifier> expected
[ERROR] .../api/ExampleApi.java:[48,192] = expected
Steps to reproduce
  1. Generate code using maven plugin with the following configuration:
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>4.3.1</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <inputSpec>${project.basedir}/src/main/openapi/spec.yaml</inputSpec>
                <generatorName>spring</generatorName>
                <generateSupportingFiles>false</generateSupportingFiles>
                <configOptions>
                    <library>spring-boot</library>
                    <interfaceOnly>true</interfaceOnly>
                    <skipDefaultInterface>true</skipDefaultInterface>
                    <hideGenerationTimestamp>true</hideGenerationTimestamp>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>
Suggest a fix

paramName should be used instead if baseName

Assignee
Assign to
Time tracking