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
#1,163 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.