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
  • #3295
Closed
Open
Issue created Jul 08, 2019 by Administrator@rootContributor

[BUG][JAVA][CLIENT] JavaClient using feign generates wrong request parameter names

Created by: stephanpelikan

Description

Using the feign java client the parameter names used in the request are named according Java rules not as defined in the api description.

openapi-generator version

4.0.2

OpenAPI declaration file content or url

openapi: 3.0.0
info:
  description: TEST API
  version: "1.0"
  title: test
servers:
  - url: /
paths:
  /test/j_security_check:
    post:
      tags:
      - test
      summary: performs login
      operationId: performLogin
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: "#/components/schemas/LoginForm"
      responses:
        200:
          description: successful login
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Success"
components:
  schemas:
    Success:
      type: object
      properties:
        test:
          type: string
    LoginForm:
      type: object
      required:
      - j_username
      - j_password
      properties:
        j_username:
          type: string
        j_password:
          type: string

Command line used for generation

			<plugin>
				<groupId>org.openapitools</groupId>
				<artifactId>openapi-generator-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>generate-test-client</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<inputSpec>${project.basedir}/src/main/resources/client/test/v1.yml</inputSpec>
							<output>${project.basedir}/generated-client-sources</output>
							<generatorName>java</generatorName>
							<apiPackage>de.mhb.test.client.v1</apiPackage>
							<modelPackage>de.mhb.testclient.v1</modelPackage>
							<invokerPackage>de.mhb.testclient.v1</invokerPackage>
							<configOptions>
								<sourceFolder>openapi</sourceFolder>
								<java8>false</java8><!-- avoid build interface default implementations -->
								<dateLibrary>java8</dateLibrary><!-- use OffsetDateTime -->
								<ensureUniqueParams>false</ensureUniqueParams>
							</configOptions>
							<library>feign</library>
							<addCompileSourceRoot>true</addCompileSourceRoot>
						</configuration>
					</execution>
				</executions>
			</plugin>
  1. build client using maven and given yml file
  2. call method performLogin

Request parameters are "jUsername" and "jPassword" instead of "j_username" and "j_password".

Suggest a fix

In https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache replace all occurencies of

@Param("{{paramName}}")

by

@Param("{{baseName}}")
Assignee
Assign to
Time tracking