swagger-api / swagger-api/swagger-parser
Swagger swagger = Swagger20Parser().parse(swaggerAsString), swagger.getDefinitions() doesn't return those definition which are not object/array type
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Below is the version which I have used:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-inflector</artifactId>
<version>2.0.0</version>
</dependency>
Below is the swagger which I have tried. It did not return 'country' as a model.
{
"swagger": "2.0",
"info": {
"title": "Pes Api Service",
"description": "A basic implementation to generate a PES API service, which accepts a JSON format payment and returns a JSON payload",
"version": "v1",
"x-artifact_id": "pes-api"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/payments": {
"post": {
"tags": [
"PaymentExecutionService"
],
"operationId": "postPayments",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [{
"name": "PaymentSDPData",
"in": "body",
"description": "SDP based payload with relevant instruction data, meta data and supplementary data",
"required": true,
"schema": {
"$ref": "#/definitions/PaymentSDPData"
}
}],
"responses": {
"200": {
"description": "Successful Operation"
},
"400": {
"description": "Bad Request"
},
"500": {
"description": "Internal Server Error"
}
}
}
}
},
"definitions": {
"country": {
"type": "string",
"pattern": "^[A-Z]{2,2}$"
},
"PaymentSDPData": {
"title": "details",
"type": "object",
"properties": {
"type": {
"type": "string",
"minLength": 1,
"maxLength": 35
},
"date": {
"type": "string",
"pattern": "^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}$"
},
"country": {
"$ref": "#/definitions/country"
},
"code": {
"type": "string",
"minLength": 1,
"maxLength": 10
},
"amount": {
"type": "number",
"format": "double"
}
}
}
}
}
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 at Swagger20Parser().parse(swaggerAsString) and inspect how getDefinitions() handles the definitions map, especially the string-typed country schema referenced by PaymentSDPData. Reproduce the supplied Swagger document and consider the issue resolved when getDefinitions() includes country as well as PaymentSDPData.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100