Importing swagger.json return "Invalid input" error

Describe the bug
I have setup a simple asp.net core test project, added “Swashbuckle.AspNetCore” version 4.0.1, and i am now trying to import the generated swagger.json file. When trying to do so, postman simply returns “Invalid input”

To Reproduce
Try to import this content:

{
	"swagger": "2.0",
	"info": {
		"title": "Lobby"
	},
	"paths": {
		"/api/lobby/users": {
			"post": {
				"tags": [
					"Lobby"
				],
				"operationId": "CreateUser",
				"consumes": [],
				"produces": [
					"text/plain",
					"application/json",
					"text/json"
				],
				"parameters": [
					{
						"name": "username",
						"in": "query",
						"required": false,
						"type": "string"
					}
				],
				"responses": {
					"200": {
						"description": "Success",
						"schema": {
							"type": "string"
						}
					}
				}
			}
		}
	},
	"definitions": {}
}

This will yield “Invalid input”.

Postman version is 7.2.2

Hey @DavyPostMan,

You seem to be missing the version parameter in the info object, this is a required field.

Adding this to your schema would allow you to create the collection, I’ve added a dummy property and value to your schema:

{
	"swagger": "2.0",
	"info": {
		"title": "Lobby",
		"version": "0.0.1"
	},
	"paths": {
		"/api/lobby/users": {
			"post": {
				"tags": [
					"Lobby"
				],
				"operationId": "CreateUser",
				"consumes": [],
				"produces": [
					"text/plain",
					"application/json",
					"text/json"
				],
				"parameters": [
					{
						"name": "username",
						"in": "query",
						"required": false,
						"type": "string"
					}
				],
				"responses": {
					"200": {
						"description": "Success",
						"schema": {
							"type": "string"
						}
					}
				}
			}
		}
	},
	"definitions": {}
}

You can validate your schema using tools like this one:

https://apidevtools.org/swagger-parser/online/

Thanx, very usefull link!

1 Like