Repository navigation
Closed
Description
Similar to Issue #749, JSON references inside the requestBody's schema property are not properly resolved.
Main OAS 3.0 file:
openapi: 3.0.0
info:
title: ref test
version: '1.0'
servers:
- url: 'http://localhost:8000/'
paths:
/user/login:
post:
summary: Login
operationId: loginUser
requestBody:
required: true
content:
application/json:
schema:
$ref: "schemas.yaml#/User"
components:
schemas: {}
Additional schema file:
User:
type: "object"
properties:
Name:
type: "string"
Password:
type: "string"
format: "password"
Run this code:
OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
String inputSpec = "main.yaml";
OpenAPI openAPI = openApiParser.readLocation(inputSpec, null, options).getOpenAPI();
String string = Yaml.mapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
System.out.println(string);
Current Value:
openapi: "3.0.0"
info:
title: "ping test"
version: "1.0"
servers:
- url: "http://localhost:8000/"
paths:
/user/login:
post:
summary: "Login"
operationId: "loginUser"
requestBody:
content:
application/json:
schema:
$ref: "schemas.yaml#/User"
required: true
components:
schemas: {}
extensions: {}
Expected Value:
openapi: "3.0.0"
info:
title: "ping test"
version: "1.0"
servers:
- url: "http://localhost:8000/"
paths:
/user/login:
post:
summary: "Login"
operationId: "loginUser"
requestBody:
content:
application/json:
schema:
$ref: "#components/schemas/User"
required: true
components:
schemas:
User:
type: "object"
properties:
Name:
type: "string"
Password:
type: "string"
format: "password"
extensions: {}
Tested with version 2.0.0-SNAPSHOT from Sonatype OSS
Metadata
Metadata
Assignees
Labels
No labels
Activity
ymohdriz commentedon Jul 12, 2018
Hi @philippwinter
I have raised a PR (#769) for this issue.
Thanks,
Mohammed
ymohdriz commentedon Jul 20, 2018
Hi @philippwinter,
You can close this issue as PR #769 is merged.
Thanks,
Mohammed
gracekarina commentedon Aug 10, 2018
Closed by #769