Skip to content

[BUG] [JAVA] InputSpecRootDirectory not working properly when we use path parameters - OpenAPI version 3.1.0 #21671

@chandu1a

Description

@chandu1a

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I have multiple Open API Yaml files which have paths containing path parameters.
When I generate the APIs individually from them using the inputSpec option it works as expected.
When I use the InputSpecRootDirectory option, the _merged_spec.yaml which is generated does not have the path parameters escaped properly.

The generated _merged_spec.yaml file contains paths like the below one which causes the validator to fail.

---
servers:
- url: "http://localhost:8080"
openapi: "3.1.0"
paths:
  /example-api/{param_a}:
    $ref: "./other-openapi.yaml#/paths/~1example-api~1{param_a}"

However what SHOULD be generated is the below as per
https://stackoverflow.com/questions/44150758/swagger-2-0-multiple-path-objects-with-different-paths-but-same-request-and-res/44164413#44164413

---
servers:
- url: "http://localhost:8080"
openapi: "3.1.0"
paths:
  /example-api/{param_a}:
    $ref: "./other-openapi.yaml#/paths/~1example-api~1%7Bparam_a%7D"
openapi-generator version

7.14.0

OpenAPI declaration file content or url
openapi: "3.1.0"
info:
  title: "Example API"
  description: "Example API"
  version: "1.0.0"
tags:
  - name: ExampleAPI
paths:
  /example-api/{param_a}:
    get:
      summary: "Example summary"
      operationId: "getExampleOperation"
      tags:
        - ExampleApi
      parameters:
        - name: "param_a"
          in: "path"
          required: true
          schema:
            type: "string"
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "schemas/example-schemas.yaml#/components/schemas/ExampleResponse"
Generation Details

This was generated using the Maven Plugin version

Steps to reproduce

Generate using the Maven Plugin with the InputSpecRootDirectory option

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions