Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger 2 validation allows path params to be non-required #1249

Closed
gexclaude opened this issue Nov 12, 2019 · 4 comments
Closed

Swagger 2 validation allows path params to be non-required #1249

gexclaude opened this issue Nov 12, 2019 · 4 comments

Comments

@gexclaude
Copy link

As the spec states, path params are always required:
https://swagger.io/docs/specification/2-0/describing-parameters/

We encountered, that this validation is not performed in swagger-parser version 1.0.47.

A small example defining a path with two path params - one is required=true and one is required=false. This appears valid when reading with new SwaggerParser().readWithInfo(content);

{
  "swagger": "2.0",
  "info": {
	"version": "1.0.0",
	"title": "Example API"
  },
  "host": "example.com",
  "basePath": "/",
  "paths": {
	"/api/admin/{account}/users/{user}": {
	  "post": {
		"operationId": "addUser",
		"parameters": [
		  {
			"name": "account",
			"in": "path",
			"required": true,
			"type": "string"
		  },
		  {
			"name": "user",
			"in": "path",
			"required": false,
			"type": "string"
		  }
		],
		"responses": {
		  "200": {
			"description": "OK"
		  },
		}
	  }
	},
  }
}

However editor complains, which is correct in my opinion:
image

@gexclaude
Copy link
Author

It may relate to #1111

@gexclaude
Copy link
Author

It appears that the parser does not perform validation against the JSON schema. Is this intentional?

gracekarina added a commit that referenced this issue Jan 31, 2020
@GORA-SAG
Copy link
Contributor

GORA-SAG commented Feb 7, 2020

Hi @gexclaude ,
As you can see the issue has been fixed. The fix will be available in 1.0.50. So, Kindly mark it as closed.

Regards,
Gokul Raj S

gracekarina added a commit that referenced this issue Feb 7, 2020
@gexclaude
Copy link
Author

Thank you a lot for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants