OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] QueryParam instead of PathParam generated

Open
#21,942 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
Description

In the project we have multiple Open API Yaml files which are generated together with the InputSpecRootDirectory option. The deliverySlot parameter is defined in routes.yaml as QueryParam and in timetables.yaml as PathParam. As a result for both yaml files the deliverySlot was generated as QueryParam.

When the APIs are generated individually using the inputSpec option, then the QueryParam and PathParam annotations are set properly.

openapi-generator version

7.15.0

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: "Route API"
paths:
  /routes/{routeId}/compute-position:
    get:
      summary: Compute a valid position on a route.
      operationId: computePosition
      parameters:
        - $ref: '#/components/parameters/routeId'
        - $ref: '#/components/parameters/deliverySlot'
        responses:
          200:
            description: Ok
            content:
              application/json:
                schema:
                  type: boolean 
components:
  parameters:
    routeId:
      description: The identifier of a route.
      name: routeId
      in: path
      required: true
      schema:
        type: string

    deliverySlot:
      description: A delivery slot.
      name: deliverySlot
      in: query
      required: true
      schema:
        type: string
openapi: 3.0.1
info:
  title: "Timetables API"
paths:
  /timetables/{deliverySlot}/timeSlot:
    get:
      summary: Get the time slot for a delivery slot.
      operationId: getTimeSlot
      parameters:
        - $ref: '#/components/parameters/deliverySlot'
               responses:
          200:
            description: Ok
            content:
              application/json:
                schema:
                  type: string
components:
  parameters:
    deliverySlot:
      description: A delivery slot.
      name: deliverySlot
      in: path
      required: true
      schema:
        type: string
Generation Details

Maven Plugin
generatorName: jaxrs-spec

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 with the Maven Plugin generation path for jaxrs-spec and compare parameter handling when using InputSpecRootDirectory versus inputSpec. Reproduce the issue with the two YAML snippets, checking why the shared deliverySlot definition causes the timetable parameter to use QueryParam; done means separate QueryParam and PathParam annotations are generated correctly.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.