swagger-2.0

SwaggerUI not displaying Model Schema

喜欢而已 提交于 2019-12-22 18:01:42
问题 I have a C# Web.API project with Swagger and Swashbuckle. I have a model: public class TimeZoneName { public string zoneName { get; } } I have a controller with methods: public string GetLocalTimeByTimeZone(TimeZoneName timezone) { //Stuff Happens here return "12:00"; } During a build I was expecting Swashbuckle to generate a SwaggerUI that shows a JSON representation of the TimeZoneName type in the UI. That didn't occur. How do I set up my methods and models so that the Model Schema is shown

Swagger UI empty and gives 403

不想你离开。 提交于 2019-12-22 13:30:18
问题 I'm using spring boot and I've added swagger to my dependencies: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.8.0</version> </dependency> My configuration: @Configuration @EnableSwagger2 public class SwaggerConfiguration { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select()

How to change the response status code for successful operation in Swagger?

↘锁芯ラ 提交于 2019-12-22 04:28:20
问题 As shown in the image, it says "Response Class (Status 200)" for the add operation. However, the add operation has been implemented in such a way that it will never return 200. It returns 201 on success. My question is how can I change the (Status 200) to (Status 201)? The code for this part is as follows: @RequestMapping(method = RequestMethod.PUT, value = "/add") @ApiOperation(value = "Creates a new person", code = 201) @ApiResponses(value = { @ApiResponse(code = 201, message = "Record

How to define global parameters that will apply to all paths?

梦想与她 提交于 2019-12-22 03:52:39
问题 I want to make the account parameter to be applied to all paths, without any exceptions. Is there any way to do this with Swagger 2? I don't want apply the account parameter for every path. { "swagger": "2.0", "info": { "version": "1.0", "title": "Doc" }, "host": "localhost", "schemes": [ "http" ], "produces": [ "application/json" ], "parameters": { "account": { "in": "header", "name": "X-ACCOUNT", "description": "Account id", "type": "string", "required": true } }, "paths": { "/account": {

How can I tell Swashbuckle that the body content is required?

徘徊边缘 提交于 2019-12-21 04:29:13
问题 I have a WebAPI controller that accepts binary packages and stores them somewhere. As these packages can become quite large, I don't want to load them into memory by adding a byte array parameter but rather pass along a stream. I found a way to do that in this answer: [HttpPost] [Route("Store/{projectId}")] public async Task Store(string projectId) { using (var stream = await this.Request.Content.ReadAsStreamAsync()) { await this.packageManager.StorePackageAsync(projectId, stream); } } This

Using Swashbuckle for Asp.net core how can I add a model to the generated model list?

天涯浪子 提交于 2019-12-21 01:15:00
问题 I'm using Swashbuckle with ASP.net core. It is producing a nice website with a list of models at the bottom. How can I add a model to this list that isn't already appearing? I return an abstract class in one of my requests and I want to list all the variations that inherit that abstract class. Thanks in advance 回答1: You could create an document filter and register it globally. public class CustomModelDocumentFilter<T> : IDocumentFilter where T : class { public void Apply(SwaggerDocument

How to send Authorization header with a request in Swagger UI?

别来无恙 提交于 2019-12-20 17:32:37
问题 I have a ASP.NET Web Api 2 application. I added Swashbuckle to it (Swagger for .NET). It displays my endpoints no problem, but in order to send a request I need to attach an Authorization header to that request. If I understand correctly in order to do that I need to modify the index.html file (https://github.com/swagger-api/swagger-ui#how-to-use-it) so I git cloned Swashbuckle project in order to modify index.html and add some headers. Is that the only way to send Authorization header with

Swagger UI Multi level tagging

丶灬走出姿态 提交于 2019-12-20 03:32:20
问题 I just started working on Swagger api 2.0 recently.I am looking for some ways to organize the API documentation. Currently am using @Api(tags = {"Heading1"}) annotation to tag each api. Now the documentation looks like Tasks --------->Heading1 -------->Desc1 --------->Desc2 ---------->Heading2 --------->Desc3 --------->Desc4 But i am looking for adding some subheadings in the doc ,so that it looks like Tasks --------->Heading1 -------->Desc1 --------->SubHeading1 --------->Desc2 ----------

Following swagger specifications, how can I define json of nested objects to yaml?

北战南征 提交于 2019-12-19 19:44:57
问题 I am having a problem in defining the array of objects in swagger yaml. Swagger editor is giving an error everytime I try to define the type: array part of the yaml. I defined it, but it is not right as it is giving an error. Following is the json I am trying to define in swagger yaml. { "CountryCombo": { "options": { "option": [{ "id": "GB", "value": "GB Great Britain" }, { "id": "US", "value": "US United States" }, { "id": "AD", "value": "AD Andorra, Principality of" }] } } } I defined this

Following swagger specifications, how can I define json of nested objects to yaml?

对着背影说爱祢 提交于 2019-12-19 19:44:32
问题 I am having a problem in defining the array of objects in swagger yaml. Swagger editor is giving an error everytime I try to define the type: array part of the yaml. I defined it, but it is not right as it is giving an error. Following is the json I am trying to define in swagger yaml. { "CountryCombo": { "options": { "option": [{ "id": "GB", "value": "GB Great Britain" }, { "id": "US", "value": "US United States" }, { "id": "AD", "value": "AD Andorra, Principality of" }] } } } I defined this