swagger-api / swagger-api/swagger-codegen

[Java-JaxRS-spec] Path parameter pattern

Open
#7,688 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

In the swagger definition I can specify a pattern for a path parameter. When generating code, this pattern is not used in the @Path annotation for Jax-RS, using version 2.2.1.

For example, if my spec can contain an operation of the form:

paths:
  '/customer/{customerID}':
    get:
      summary: Get a customer
      operationId: getCustomer
      parameters:
          - name: customerID
            in: path
            required: true
            type: string
            pattern: c-\\d+
      responses:
        200:
          description: successful operation

I would like my generated API to have the following annotation:

@Path("/{customerID: c-\\d+}")

Currently, it will result in:

@Path("/{customerID}")

Is this fixed in a later version?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Java JAX-RS generation for the @Path annotation and how path-parameter patterns from the Swagger definition are handled. Compare the generated annotation with the issue's c-\d+ example; done means the pattern is included in the generated @Path value.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.