Open
Description
I am trying to parse an OpenAPI definition on a windows machine. The parsed OpenAPI is missing the requestBody which refers to a custom schema called User
in this case. I have included the yaml file and also the parse output from debugging.
Following is the java code. I am using implementation "io.swagger.parser.v3:swagger-parser:2.0.24"
dependency to parse.
String definitionPath = "G:\\openapi\\src\\test\\resources\\requestBody.yaml"
OpenAPI api = new OpenAPIV3Parser().read(definitionPath);
I found that parsing fails midway at:
Following is the content of the requestBody.yaml
file:
openapi: 3.0.0
info:
title: refComponent
description: refComponent
version: 1.0.0
servers:
- url: 'https'
paths:
/requestBody:
post:
summary: Creates a new user.
responses:
200:
description: OK
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
required:
- userName
properties:
userName:
type: string
firstName:
type: string
lastName:
type: string
The output of the parsing:
class OpenAPI {
openapi: 3.0.1
info: class Info {
title: refComponent
description: refComponent
termsOfService: null
contact: null
license: null
version: 1.0.0
}
externalDocs: null
servers: [class Server {
url: /
description: null
variables: null
}]
security: null
tags: null
paths: class Paths {
{/requestBody=class PathItem {
summary: null
description: null
get: null
put: null
post: class Operation {
tags: null
summary: Creates a new user.
description: null
externalDocs: null
operationId: null
parameters: null
requestBody: null
responses: class ApiResponses {
{200=class ApiResponse {
description: OK
headers: null
content: class Content {
{}
}
links: null
extensions: {}
$ref: null
}}
extensions: null
}
callbacks: null
deprecated: null
security: null
servers: null
}
delete: null
options: null
head: null
patch: null
trace: null
servers: null
parameters: null
$ref: null
}}
}
components: class Components {
schemas: null
responses: null
parameters: null
examples: null
requestBodies: null
headers: null
securitySchemes: null
links: null
callbacks: null
}
}
Metadata
Metadata
Assignees
Labels
No labels