-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
When using ParserOption.resilveFully(true) and the response schema is a map (or uses a schema that contains a map), the references are not fully resolved and left as $ref
Example:
openapi: 3.0.0
servers:
- url: 'http://localhost:8080/sample'
info:
description: A simple API to learn how to write OpenAPI Specification
version: 1.0.1
title: Simple API
paths:
/sample:
get:
tags:
- Sample
operationId: getSample
responses:
'200':
description: Sample
content:
application/json:
schema:
$ref: '#/components/schemas/MyModelMap'
components:
schemas:
MyModel:
type: object
properties:
name:
type: string
MyModelMap:
type: object
additionalProperties:
$ref: "#/components/schemas/MyModel"
When this code is run against this schema:
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().readLocation("openapi.yaml", null, options).getOpenAPI();
String yaml = Yaml.pretty(openAPI);
Results in this output:
openapi: 3.0.0
info:
title: Simple API
description: A simple API to learn how to write OpenAPI Specification
version: 1.0.1
servers:
- url: http://localhost:8080/sample
paths:
/sample:
get:
tags:
- Sample
operationId: getSample
responses:
200:
description: Sample
content:
application/json:
schema:
type: object
additionalProperties:
$ref: '#/components/schemas/MyModel'
components:
schemas:
MyModel:
type: object
properties:
name:
type: string
MyModelMap:
type: object
additionalProperties:
$ref: '#/components/schemas/MyModel'
I have created this PR with the fix and corresponding test:
Metadata
Metadata
Assignees
Labels
No labels