swagger

How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning

二次信任 提交于 2020-06-09 09:27:14
问题 We have asp.net core webapi. We added Microsoft.AspNetCore.Mvc.Versioning and Swashbuckle to have swagger UI. We specified controllers as this: [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/[controller]")] public class ContactController : Controller { When we run swagger ui we get version as parameter in routes: How to set-up default "v1" for route ? If version 2 come to the stage how support swagger ui for both versions ? 回答1: At the moment Swashbuckle and Microsoft.AspNetCore.Mvc

Configure Swagger Authentication with Firebase (google) in .Net core

久未见 提交于 2020-06-08 15:12:05
问题 Integrating swagger and firebase is really hard because google token request and response is not standard. so I used password flow and add a middleware in .net core 3.1 Web API to authenticate swagger 5.x I hope it helps. The first step is configuring your API to use Firebase for token validation. so we need to add this code to the startup. services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme =

Swagger Editor 3.8 examples not working for reference array schema

百般思念 提交于 2020-06-01 05:09:05
问题 This question is a follow-up to this similar one - as @Helen requested a new question be asked. It seems an array type schema only accepts "example", not "examples". The following schema produces an error on the editor.swagger.io site: info: title: Example Inc. REST API version 1.0 version: '1.0' openapi: 3.0.0 components: schemas: user_reference: properties: comment: type: string middle_name: type: string domain: pattern: '^[0-9A-Za-z][0-9A-Za-z.-]*$' type: string id: minimum: 1 type:

Swagger Editor 3.8 examples not working for reference array schema

限于喜欢 提交于 2020-06-01 05:09:00
问题 This question is a follow-up to this similar one - as @Helen requested a new question be asked. It seems an array type schema only accepts "example", not "examples". The following schema produces an error on the editor.swagger.io site: info: title: Example Inc. REST API version 1.0 version: '1.0' openapi: 3.0.0 components: schemas: user_reference: properties: comment: type: string middle_name: type: string domain: pattern: '^[0-9A-Za-z][0-9A-Za-z.-]*$' type: string id: minimum: 1 type:

Swagger crashes with circular model references

五迷三道 提交于 2020-05-30 03:42:17
问题 I have a .Net Core 2.2 OData API, for which I'm tying to implement Swagger documentation. I've been following this example: https://github.com/Microsoft/aspnet-api-versioning/tree/master/samples/aspnetcore/SwaggerODataSample I've got it working up to a point. Now I'm facing an issue with my models referencing each other in a circular manner, let me explain: Note: I used EFCore Code first approach for handling my DB. I have these models (as an example): Project, ProjectLocation, ProjectRegion.

splitting swagger definition across many files

試著忘記壹切 提交于 2020-05-29 03:59:19
问题 Question: how can I split swagger definition across files? What are the possibilities in that area? The question details are described below: example of what I want - in RAML I do have experience in RAML and what I do is, for example: /settings: description: | This resource defines application & components configuration get: is: [ includingCustomHeaders ] description: | Fetch entire configuration responses: 200: body: example: !include samples/settings.json schema: !include schemas/settings

How do I setup Swashbucle v5 with swagger when I have a custom base url?

拟墨画扇 提交于 2020-05-27 13:23:27
问题 I am upgrading a .net API to .net Core 3.1 and using Swashbuckle.AspNetcore 5.4.1. The API is running inside a ServiceFabric app. I found this https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1173 and tried to follow that and swagger gets generated but if I try to use the Swagger UI to send requests the request URL is with the wrong IP so the request fail. In the old Swashbuckle 4.0.1 setup we did not specify host, only the reelative basePath. How can I archieve the same?

How to integrate Swagger with Maven + Java + Jersey +Tomcat

℡╲_俬逩灬. 提交于 2020-05-26 10:46:17
问题 I can't seem to understand how to integrate Swagger to generate API documentation. url: ####:8080/MyService/rest/users/getall I have added Annotations to code and dependency. I try to visit: ####:8080/MyService/rest/ but says its not found. //web.xml <servlet> <servlet-name>mycompany-users-serlvet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com

Secure swagger docs page with username and password Asp Net Core 2.1

谁都会走 提交于 2020-05-26 04:17:19
问题 I am using Asp.Net Core 2.1 Web Api with Swashbuckle.aspnetcore.swagger I want to secure api documentation page with username and password before granting access. Sample documention page To make sure its not accessible by the public 回答1: Copied from mguinness's answer on Github: In .NET Core you use middleware, instead of a DelegatingHandler: public class SwaggerAuthorizedMiddleware { private readonly RequestDelegate _next; public SwaggerAuthorizedMiddleware(RequestDelegate next) { _next =

Swagger for Micronaut with maven

隐身守侯 提交于 2020-05-25 23:54:24
问题 I want to switch to the Micronaut framework from Spring Boot 2. And I am struggling with the Swagger settings. In Spring Boot 2 project I have the following dependencies: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.1</version> </dependency> and SwaggerConfig.class: @Configuration @EnableSwagger2 public class