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
  • #7791
Closed
Open
Issue created Oct 22, 2020 by Administrator@rootContributor

[REQ] Feign client support for custom method syntax

Created by: dean-eastwood

Is your feature request related to a problem? Please describe.

The Feign client generator automatically converts path template expressions variables to camelCase when creating the client interface. The mechanism used for converting the template expression caters for parameters appearing between / separators and assumes that all path parameters begin with { and end with }.

For example, when using the following path definition:

  paths:
  /events/{event_id}:
    post:
      operationId: undeleteOperation
      parameters:
        - name: event_id
          in: path
          required: true
          description: Event Id
          schema:
            type: number
      responses:
        200:
          description: success

The feign client generator finds the path parameter event_id and "camelizes" it to eventId. The parameter definition of event_id is also "camelized" to eventId. This results in the following interface method definition:

  @RequestLine("POST /events/{eventId}")
  @Headers({
    "Accept: application/json",
  })
  void undeleteOperation(@Param("eventId") BigDecimal eventId);

If you have a pre-existing openapi spec that uses snake_case path parameter names and also implements custom methods, the client generator may fail to match the path parameters described on the path template expression, resulting in invalid feign interface method definitions. The problem being that a path parameter may be immediately followed by a :customMethod.

For example, when using the following path definition, with a custom method of undelete:

paths:
  /events/{event_id}:undelete:
    post:
      operationId: undeleteOperation
      parameters:
        - name: event_id
          in: path
          required: true
          description: Event Id
          schema:
            type: number
      responses:
        200:
          description: success

The feign client generator is unable to find the path parameter event_id, however, the parameter definition of event_id is still "camelized" to eventId. This results in the following invalid interface method definition:

  @RequestLine("POST /events/{event_id}:undelete")
  @Headers({
    "Accept: application/json",
  })
  void undeleteOperation(@Param("eventId") BigDecimal eventId);

The name of the path parameter in the @RequestLine annotation does not match the @Param annotation in the method argument.

Describe the solution you'd like

Custom methods are not formally part of the URI specification, however they are also not disallowed by either the URI specification or by the OpenApi Specification 3.1.0-rc1 (that I can find).

I think it would make sense to support "camelization" of path parameters using custom method syntax on paths, unless there is some specific reason why it must not be supported.

A solution would be to update the java client code generator to identify path parameters using an updated matching algorithm taking into account the potential for custom methods.

I will submit a PR against this feature request to demonstrate a potential solution.

Describe alternatives you've considered

Manually renaming all alternative cased path parameters to camelCase would make the problem go away.

Additional context

Assignee
Assign to
Time tracking