swagger

How to extend FastAPI docs with another swagger docs?

久未见 提交于 2021-01-27 16:13:05
问题 I decided to make a micro-services gateway in Python's FastApi framework. My authorization service is written in Django and there are already generated by drf-yasg package swagger docs. I was thinking if there is a way to somehow import auth's schema to the gateway. I can serve the schema in json format via http and access it from the gateway. The question is how to integrate FastApi's docs with raw swagger schema file. 回答1: According to docs you can modify the openAPI json. Example: from

how to pass json to SwaggerUIBundle

懵懂的女人 提交于 2021-01-27 13:12:47
问题 Is there a way to pass json directly to SwaggerUIBundle instead of pass url? I want to use swagger-ui instead of SwaggerUIBundle, but I am also using react ^16, and wagger-ui doesn't support swagger-ui. So, I change to use SwaggerUIBundle. Please anyone know either how to use swagger-ui in react version 16+ or pass json into SwaggerUIBundle? Thx and appreciated! 回答1: To pass the spec as JSON, use the spec parameter: const ui = SwaggerUIBundle({ // BEGIN SPEC spec: { swagger: '2.0', info: {

How to provide authentication in Swagger API on Spring Boot application

牧云@^-^@ 提交于 2021-01-27 13:10:56
问题 I have integrated Swagger to generate API documentation for Spring REST application using Spring Boot. It works well, I could see the generated API documentation when I hit the URL : http://localhost:8080/test/swagger-ui.html My question is how can I restrict the access to the API? Basic authentication based on hardcoded username and password should be good enough for at least to start with. I used maven to add "swagger2" dependency. Here is the pom.xml: <dependency> <groupId>io.springfox<

A list of GUIDs is empty when passed into a model which is used by [FromForm] in ASP.NET Core 2.2

◇◆丶佛笑我妖孽 提交于 2021-01-27 12:15:04
问题 EDIT: THE ISSUE LIES WITH SWAGGER. SEE THE ANSWER FOR MY OWN FIX. I am currently experiencing some issues with passing a list of GUID's to a controller action by using HTTP POST and [FromForm] . The list of guids is EMPTY. If I try to turn it into a list of strings, instead of having 3 values, only 1 value is seen in the list and it is a string that contains the 3 values but comma seperated. The reason why I use [FromForm] is because I need to upload a file but ALSO pass some other data to

How to send Authorization header with a request in swagger-ui-react?

橙三吉。 提交于 2021-01-27 11:42:23
问题 I use swagger-ui-react in my application. But I don't know how to config to add the authorization into api requests. I had found an answer use in swagger ui from here: window.swaggerUi = new SwaggerUi({...}) ... swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", "header")); But I don't know how to use in swagger-ui-react. Here is my code: import styles from './index.less'; import React from 'react'; // tslint

How to send Authorization header with a request in swagger-ui-react?

断了今生、忘了曾经 提交于 2021-01-27 11:41:19
问题 I use swagger-ui-react in my application. But I don't know how to config to add the authorization into api requests. I had found an answer use in swagger ui from here: window.swaggerUi = new SwaggerUi({...}) ... swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", "header")); But I don't know how to use in swagger-ui-react. Here is my code: import styles from './index.less'; import React from 'react'; // tslint

How to make SpringFox Swagger render a string parameter as another model type?

时光总嘲笑我的痴心妄想 提交于 2021-01-27 08:15:39
问题 How can I make Swagger document a String resource parameter as a full class type? I.e. I have this resource declaration: @PatchMapping(path="/{id}") public ApiResponse<MyObject> patch(@PathVariable String id, @RequestBody String myObjText) { I want myObjText to be documented as having a model of type MyObject while still be able to get the raw JSON text in the method body (that's because I later want to call readerForUpdating() over a Jackson objectMapper ). @ApiParam seems to be ignored for

Howto use custom templates in Swagger

给你一囗甜甜゛ 提交于 2021-01-27 05:11:29
问题 I have this JavaJaxRs dictionary with my templates: /templates/JavaJaxRs I edited some of them. And want to use them for my API generation (Code was inspired from this approach from https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java): System.out.println("Generating API for: " + location); DefaultGenerator generator = new DefaultGenerator(); Swagger swagger = new SwaggerParser().read(location)

Howto use custom templates in Swagger

隐身守侯 提交于 2021-01-27 05:11:26
问题 I have this JavaJaxRs dictionary with my templates: /templates/JavaJaxRs I edited some of them. And want to use them for my API generation (Code was inspired from this approach from https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java): System.out.println("Generating API for: " + location); DefaultGenerator generator = new DefaultGenerator(); Swagger swagger = new SwaggerParser().read(location)

How can I configure “HTTPS” schemes with the drf-yasg auto-generated swagger page?

南笙酒味 提交于 2021-01-26 11:01:11
问题 I know in a traditional swagger YAML file, we can define the schemes with: schemes: - http - https //OR schemes: [http, https] However, how can I do the same thing with auto-generated swagger page with the drf-yasg library? Now, the generated swagger page only contains HTTP schemes, but HTTPS is missing. I've tried set the DEFAULT_API_URL in setting.py to https://mybaseurl.com , but it seems not to be working. 回答1: There is a solution. When defining get_schema_view() in urls.py , use this