OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] InputSpecRootDirectory not working properly when we use path parameters - OpenAPI version 3.1.0
Nobody has claimed this yet.
- 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?
- [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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Maven Plugin and the InputSpecRootDirectory option using the supplied OpenAPI 3.1.0 example. Trace the generation of _merged_spec.yaml and compare its path-parameter $ref encoding with the expected %7Bparam_a%7D form; done means the merged file passes validation while individual inputSpec generation remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100