OpenAPITools / OpenAPITools/openapi-generator
[BUG] Resolve Fully does not work?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi folks,
I am new in OpenAPI,
I have the following yaml file:
openapi: 3.0.1
info:
title: ping test
version: '1.0'
servers:
- url: 'http://localhost:888888/'
paths:
/some/ping:
get:
operationId: AAAAA
responses:
'201':
description: OK
content:
application/json:
schema:
$ref: 'some-swagger-response.yaml'
components:
schemas: {}
What I want is to get an String output, containing all the output above and resolving the "$ref".
This is my code snippet:
String inputSpec = "./src/main/java/swagger-reference-response.yaml";
OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
options.setFlatten(false);
OpenAPI openAPI = openApiParser.readLocation(inputSpec, null, options).getOpenAPI();
String string = Yaml.mapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
System.out.println(string);
The output of the String is:
`openapi: 3.0.1
info:
title: ping test
version: "1.0"
servers:
- url: http://localhost:888888/
paths:
/some/ping:
get:
operationId: AAAAA
responses:
"201":
description: OK
content:
application/json:
schema:
type: object
components:
schemas:
some-swagger-response:
type: object`
How can I get the full content of this file inside the String? $ref: 'some-swagger-response.yaml'
Thank you very much
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 example with OpenAPIParser, ParseOptions.setResolveFully(true), and Yaml.mapper(), using swagger-reference-response.yaml and the external some-swagger-response.yaml reference. Compare the parsed model with the serialized YAML and inspect parser tests or entry points for external-reference resolution; done means the expected referenced content is either emitted or the behavior is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100