-
Notifications
You must be signed in to change notification settings - Fork 760
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
How to define application name for try it curl requests? #1081
Comments
First - this is a swagger-ui question, not swagger-js. Second - it's likely that there's something wrong with your API definition, can you share it? |
Here API swagger.json: {
"swagger": "2.0",
"info": {
"title": "Notes Services",
"version": "1",
},
"basePath": "/api/notes/v1",
"tags": [
{
"name": "notes"
}
],
"schemes": [
"http",
"https"
],
"paths": {
"/mynotes": {
"get": {
"tags": [
"notes"
],
"summary": "Gets my notes",
"description": "",
"operationId": "retrieveMyNotes",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "priority",
"in": "query",
"description": "Priority",
"required": false,
"type": "integer",
"x-example": "1"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/NoteDto"
}
}
}
}
}
}
},
"definitions": {
"NoteDto": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"priority": {
"type": "integer",
"format": "int32"
},
"text": {
"type": "string"
}
}
}
}
} |
Your basePath is |
The problem is that context path 'my-app' is part of server container configuration which I cannot control (not part of application code). Another thing we also generate static html documentation based on same swagger.json files and context path 'my-app' in front of base path would be incorrect from clients standpoint. The closest pending feature I found which could help in current situation is #1045. However I'm not sure if |
The host cannot contain paths as well. You need to modify your basePath. Since it's generated from your code, it can be generated dynamically by the code. You don't need to control it. If you don't change it, it will break the UI, will break code generation, and pretty much make your API definition invalid. |
The only thing which does not work is 'try-it' due execution URL. Generation works fine I don't need put context path into generated docs as it does not make sense, clients on other end will have other context path anyway. I just want clarify that context path is not part of REST specification its just application entry point. In my situation url structure is: Seems swagger assumes that application entry always is |
Swagger doesn't assume anything. This is how the spec works.
If you don't change your basePath, you don't have a definition that describes your API as the spec requires it. Either change it, or it won't work. |
Thanks for clarifying |
How this issue resolved? It doesn't work when I try to change |
@Le-Zhang can't do much with that without knowing which version of swagger-ui you're using and other things. Please file a new ticket following the issue template and we'll try to help. |
I cannot find anywhere how to define application name for try it curl requests.
My Swagger page is at url:
http://localhost:8080/my-app/swagger.xhtml
(it is based on pet store sample)Services base url is
/api/notes/v1/
When I hit execute at try it curl hits service with url
http://localhost:8080/api/notes/v1/mynotes
since there no 'my-app' in path included I get 404.Application name varies from environment and I cannot simple put in swagger.json because same spec will be used for generating static docs (application name is not relevant there).
SwaggerUIBundle looks currently this way:
I'm using swagger-ui 3.0.10 from WebJar.
The text was updated successfully, but these errors were encountered: