We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If you add a tag named "models" to an API and tag a method with it, swagger-ui throws an exception.
swagger-client.js:466 Uncaught TypeError: Cannot read property 'push' of undefined
operationGroup.apis.push(operationObject);
here, operationGroup.apis is undefined
I tracked this down to swagger-client.js line 458 which does:
operationGroup = this[tag];
but this.tag is not an operations group, it is the list of models (schemas) in the API. (in this example A : Model, B : Model )
Unfortunately, this conflicts with SwaggerClient.models
This also means that any other field of the SwaggerClient object may not be used as a tag.
This should probably be stored elswwhere, such as this.operationGroups[tag]
operationGroup = this.operationGroups.[tag];
to avoid conflicting with the other members of SwaggerClient (such as basePath, title, etc.)
Here is a sample swagger.json file that causes this:
{ "swagger" : "2.0", "info" : { "title" : "issue with a tag named 'models'", "contact" : { "name" : "David Biesack", "email" : "[email protected]" }, "version" : "1" }, "tags" : [{ "name" : "tag1", "description" : "" }, { "name" : "models", "description" : "TODO: add description of models" } ], "host" : "www.example.com", "basePath" : "/", "schemes" : ["http"], "paths" : { "/" : { "get" : { "tags" : ["tag1"], "summary" : "Return a list of links to the top level collections in this REST API, as well as links to create new instances in the top level collections.", "produces" : ["application/xml", "application/json"], "responses" : { "200" : { "description" : "REST API resource collection links." } } } }, "/models/{modelId}" : { "head" : { "tags" : ["models"], "summary" : "get headers for a model", "parameters" : [{ "name" : "modelId", "in" : "path", "type" : "string", "required" : true, "description" : "String containing the id of the model." } ], "responses" : { "200" : { "description" : "Return a specific model resource status code." }, "403" : { "description" : "The project is not locked by the current user." }, "404" : { "description" : "Not found." }, "423" : { "description" : "The project is locked by a different user." } } } } }, "definitions" : { "A" : { "id" : "A", "title" : "Resource A", "properties" : { "id" : { "type" : "string", "description" : "The id." } }, "B" : { "id" : "B", "title" : "Resource B", "properties" : { "context" : { "type" : "string", "description" : "The context" } } } } } }
The text was updated successfully, but these errors were encountered:
This is a duplicate of #802. The issue is in underlying swagger-js library. swagger-api/swagger-js#194 is for addressing this issue.
Closing as duplicate
Sorry, something went wrong.
help
This should be fixed in the latest develop_2.0 build of swagger-js.
develop_2.0
swagger-js
See #1061: It is caused for tag info. Client version is 2.1.8-M1.
info
mohsen1
No branches or pull requests
If you add a tag named "models" to an API and tag a method with it, swagger-ui throws an exception.
here, operationGroup.apis is undefined
I tracked this down to swagger-client.js line 458 which does:
but this.tag is not an operations group, it is the list of models (schemas) in the API.
(in this example A : Model, B : Model )
Unfortunately, this conflicts with SwaggerClient.models
This also means that any other field of the SwaggerClient object may not be used as a tag.
This should probably be stored elswwhere, such as this.operationGroups[tag]
to avoid conflicting with the other members of SwaggerClient (such as basePath, title, etc.)
Here is a sample swagger.json file that causes this:
The text was updated successfully, but these errors were encountered: