Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger validation error on path item: "Additional properties not allowed"

I am using https://www.npmjs.com/package/swagger and I am trying to create a config. I have such a part of my swagger.js

       "dummy\/{id}\/related_dummies": {
            "get": {
                "tags": [
                    "RelatedDummy"
                ],
                "operationId": "get_by_parentRelatedDummyCollection",
                "produces": [
                    "application\/ld+json",
                    "application\/hal+json",
                    "application\/xml",
                    "text\/xml",
                    "application\/json",
                    "text\/html"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "type": "integer"
                    }
                ],
                "summary": "Retrieves the collection of RelatedDummy resources.",
                "responses": {
                    "200": {
                        "description": "RelatedDummy collection response",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#\/definitions\/RelatedDummy"
                            }
                        }
                    }
                }
            }

But when I run swagger validate swagger.js I keep getting this error:

Project Errors
--------------
#/paths: Additional properties not allowed: dummy/{id}/related_dummies
Results: 1 errors, 0 warnings

What could be the reason of the error? Thanks

like image 509
Albert Tobac Avatar asked Dec 17 '16 18:12

Albert Tobac


1 Answers

The problem is that the path dummy/{id}/related_dummies doesn't begin with a slash.

To be recognized as a valid path item object, it needs to be /dummy/{id}/related_dummies.

Using the escaped syntax from your example, the name should be "\/dummy\/{id}\/related_dummies"

The relevant part of the Swagger–OpenAPI 2.0 specification is in the Paths Object definition.

like image 138
Ted Epstein Avatar answered Sep 28 '22 02:09

Ted Epstein