Swagger UI not showing operations with same Path but different HTTP method
For example I have 2 API operations: GET v1/people/{id} POST v1/people/{id} Only one of these operations is shown in my Swagger UI API docs but I want both of them displayed. I have many examples where this is the case. In the Swagger documentation it states: "Swagger defines a unique operation as a combination of a path and an HTTP method." This would make me think what I want to do is possible as they are uniquely identified by the HTTP method. If I change the path parameter for one in my swagger.yaml file they will both show. eg: GET v1/people/{personid} POST v1/people/{id} But I would rather keep them all standard otherwise my API docs will appear messy. I am using swagger-ui-express 4.1.4. Please see StackOverflow post with code:https://stackoverflow.com/questions/62769866/swagger-ui-not-showing-operations-with-same-path-but-different-http-method Thanks for your help.SolvedDownload Excel file as a response from Open Api 3
I am editing in editor.swagger.io How can I download response from API locally which is a excel file? My snippet - responses: 200: description: "JSON to Excel conversion succeeded" content: application/vnd.ms-excel: schema: type: string format: binary I get server response of 200 saying 😱 Could not render this component, see the console In console the response headers are - cache-control: public, max-age=0 content-length: 8515 content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet expires: Tue, 10 Dec 2019 15:14:55 GMT I want to save excel file locally.SolvedCustomize Swagger-UI to serve multiple Json Files
Hello Folks, I have an application with many Rest Services and Models and now i want to generate Swagger Documentation for these services, and i just went with Swagger. I added swagger and swagger-ui to my Application and at first it looks Perfect, but once i finished adding all my Services i ended up with some problems, the major problem is the Swagger-UI , because Swagger generate one single json file api-docs for all the services, this files got big and so when i access the swagger-ui it crashes because the file is so big and the browser runs out of memory. i searched but i didn't find a solution for the swagger-ui but i found a maven plugin that can generate mutiple json files : maven-swagger-plugin so now i have different files containing different documentation for my services, but my problem now is how can i make swagger-ui dynamic so i can order one json file per time and render it in the ui. thanks2.5KViews0likes0CommentsSwagger show file content via @ExampleProperty annotation
I am using swagger 3.0.0-Snapshot to create documentation for my Spring Boot application. My maven dependencies are <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0-SNAPSHOT</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>3.0.0-SNAPSHOT</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-spring-webmvc</artifactId> <version>3.0.0-SNAPSHOT</version> </dependency> My swagger config class is as simple as possible: @Configuration @EnableSwagger2WebMvc public class SwaggerConfig { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .useDefaultResponseMessages(false) .select() .apis(RequestHandlerSelectors.basePackage("com.mycompany.cs")) .paths(PathSelectors.any()) .build() .pathMapping("/") .useDefaultResponseMessages(false); } And my controller method has the following annotation: @ApiOperation(value = "Hello world", httpMethod = "POST") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", examples = @Example(value = @ExampleProperty(mediaType = "application/json", value = exampleValue))) }) It is working and shows in Swagger UI "Example Value" field value that has constant string exampleValue that is private static String. The question is how to pass the content of json file that is in resources folder to @ExampleProperty value? I tried to read file content in static block and pass it to initialize final String with it, but then the compiler says that "Attribute value has to be constant". The content of json file must be shown in example field in Swagger UI.2.3KViews0likes0CommentsSwagger UI: authorization modal logout/authorize issue
Library version: swagger-ui-dist#3.32.5 Problem : It is not possible to authorize again inside same 'Authorization modal' after logout is clicked Steps to reproduce : 1. Click 'Authorize' button in Swagger UI 2. enter proper client id and client secrets. 3. check necessary scopes 4. click Authorize button below. 5. do proper auth actions in a separate tab. 6. After successful auth process second tab is closed and 'Logout' button appears instead of 'Authorize' (meanwhile auth token endpoint is accessed with proper authorization code) 7. click 'Logout' button (it should be disappear and 'Authorize' should appear. Also clientid+clientsecret + checkboxes remain with the same data) 8. click Authorize. 9. do necessary auth actions in separate tab 10. see next error response in 'Authorization modal' :AuthErrorError, error: invalid_grant, description: Authorization code is invalid or expired. Investigation results: 1. oauth2-redirect.html endpoint sends proper authorization code back to main tab. 2. however authActions.authorizeRequest will receive auth code from first authentication try (steps 1-5) 3. It seems redux state is not properly updated during recieving callback fromoauth2-redirect.html 4. issue is reproducible on local environment as well as in swagger hub.How we can display single API inside Swagger UI or Swagger Widget? Swagger Widget for Web available?
I am trying to create a Swagger API documentation like the attached screenshot. I have a swagger endpoint. I want to customize Swagger UI to display API document as follows: How can I create this kind of documentation? Is there any product like Swagger Widget which I can put on webpages and try out Single APIs? I am using React, ASP.Net Core and Swasbuckle Core. Pls let me know. Thanks in advance.SolvedCXF Swagger2Feature return the same swagger.json
am trying to generate swaggger documentation for our APIs. what i did is creating a bean based on the org.apache.cxf.jaxrs.swagger.Swagger2Feature: <bean id="MySwagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" abstract="true"> <property name="scanAllResources" value="true"/> <property name="title" value="Swagger API for Restful Services"/> <property name="description" value="Swagger API for Restful Services"/> <property name="version" value="1.0.0"/><!--TODO:: version --> <property name="prettyPrint" value="true"/> </bean> and then for each Service(Endpoint) i created a separate bean that extends the parent bean. exp <bean id="dashboardSwagger" parent="MySwagger2Feature"> <property name="basePath" value="/services/rest/dashboard"/> </bean> <bean id="usersSwagger" parent="MySwagger2Feature"> <property name="basePath" value="/services/rest/users"/> </bean> and then add them to the <property name="features"> , but the problem is that all the services return the same swagger.json and that is the one that comes first in the Alphabet order. so i searched the internet and some developers said that i should add <property name="usePathBasedConfig" value="true" /> to each child bean. and when i did that all the services now just return this swagger.json file. { "swagger": "2.0" } Any Suggestions please.1.3KViews0likes1CommentHow to add Authorization Header to a Rest Request in Java
Hi, I am trying to upgrade swagger-ui from 2.0 to 3.21.0. In 2.0 I used to get the user name along with base url by making the change in index.html.After that setting the user inheader of each request. The same thing I would like to do in Swagger-ui 3.21.0. Can Some one please help in this? Expected:1.how to edit index.html codeto get the one more input from GUI. 2.After getting the input how to set value in header.1.1KViews0likes0CommentsLinking to custom documentation file
Hello! I'm looking for answer for my problem: how to link to documentation from custom file? I run the swagger ui docker instance using this command 'docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui' and add some other documentation files next to the swagger.json, so I can switch between them on the site but I can't create link that opens additional file with documentation. Is exists any way to do that? Any path variable like this ip:port/#/users/search?documentation=/doc_v2.json ?Solved