swagger-ui

How do I make Swagger-UI use a YAML/JSON rather than having to put annotations on my REST controller?

≡放荡痞女 提交于 2021-02-07 18:25:09
问题 I am used to adding annotations on my REST controllers for Swagger-UI to use. However, I would prefer to point Swagger-UI at a YAML file which describes my REST controller. An example of what I want to do is shown below. (Springfox/Swagger2) DemoApplication.java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication

Swagger .netcore 3.1 in Web Api, set the date time format with swagger UI

白昼怎懂夜的黑 提交于 2021-02-07 09:12:31
问题 I am wondering if anyone can help me, I am trying to change the date format in swagger UI from 2020-03-07T14:49:48.549Z to 07-03-2020T14:49 I am trying to remove the seconds and put the date format into " dd/MM/yyyy HH:mm ", now I have tried services.AddControllers() .AddNewtonsoftJson(options => { var dateConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "dd'/'MM'/'yyyy HH:mm:ss" }; options.SerializerSettings.Converters.Add(dateConverter); options

list the api in swagger based on user roles

泪湿孤枕 提交于 2021-02-05 11:47:29
问题 I have a requirement where I want to list the api methods in swagger based on user roles. For example :- User A with basic access can use limited api methods. User B with Admin access can use all the listed api methods. I don't know how to achieve this. I am using Swashbuckle.AspNetCore Version="1.0.0" 回答1: Try using an IDocumentFilter, you can limit what the user gets in the SwaggerDocument and the swagger-ui feeds from that. Here are some examples https://github.com/heldersepu

list the api in swagger based on user roles

瘦欲@ 提交于 2021-02-05 11:45:30
问题 I have a requirement where I want to list the api methods in swagger based on user roles. For example :- User A with basic access can use limited api methods. User B with Admin access can use all the listed api methods. I don't know how to achieve this. I am using Swashbuckle.AspNetCore Version="1.0.0" 回答1: Try using an IDocumentFilter, you can limit what the user gets in the SwaggerDocument and the swagger-ui feeds from that. Here are some examples https://github.com/heldersepu

Springboot swagger with JsonView

被刻印的时光 ゝ 提交于 2021-02-04 21:15:29
问题 It's possible to integrate the swagger with @JsonView ? I have one model that I use the @JsonView to return only a few fields, but the swagger-ui shows the hole model. This is my model: public class Intimacao extends EntityBase { @Embedded @JsonView({View.Intimacao_Lista.class}) private Devedor devedor; @Embedded private Sacador sacador; @Embedded private Apresentante apresentante; @Embedded private Titulo titulo; } This is my controller: @GetMapping("/") @PreAuthorize("hasRole('ADMINISTRADOR

Bug in OpenAPI generator? Wrong format for the example value of date datatype

烈酒焚心 提交于 2021-01-29 21:24:17
问题 I'm using a openapi-generator-maven-plugin with 4.2.3 version. My configuration looks like this: <typeMappings> <typeMapping>OffsetDate=LocalDate</typeMapping> <typeMapping>OffsetDateTime=LocalDateTime</typeMapping> </typeMappings> <importMappings> <importMapping>java.time.OffsetDate=java.time.LocalDate</importMapping> <importMapping>java.time.OffsetDateTime=java.time.LocalDateTime</importMapping> </importMappings> <!-- pass any necessary config options --> <configOptions> <java8>true</java8>

How to display SwaggerResponse in XML instead of JSON

房东的猫 提交于 2021-01-29 14:29:25
问题 I want to display a response in Swagger UI in XML format instead of JSON. How I can achieve this? This is the code I want to adapt: [SwaggerResponse((int)HttpStatusCode.OK, Type = typeof(FeedModel))] public async Task<IActionResult> GetCompanyPostFeed(Guid companyId) { var feed = new FeedModel(); // Some database requests return Content(feed, "text/xml", Encoding.UTF8); } 回答1: You could try decorating the method with an attribute SwaggerProducesAttribute as described here: [SwaggerProduces(

How to mark api parameter as optional for Swagger UI for Web API 2?

℡╲_俬逩灬. 提交于 2021-01-29 03:30:29
问题 I am using Swagger for WebApi 5.5.3 nuget package for API documentation. In swagger UI it is showing required option for optional parameter. I tried XML comment option in Visual studio. Below is the API method that i want to document: /// <summary> /// Gets the history. /// </summary> /// <param name="currentPageIndex">Index of the current page.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="lastSyncDate">The last synchronize date.</param> /// <returns></returns

I am getting 404 for https://localhost:8080/swagger-ui.html

天大地大妈咪最大 提交于 2021-01-28 20:22:52
问题 I am getting a valid response for http://localhost:8080/v2/api-docs/ but while I am trying to access, I am getting http://localhost:8080/swagger-ui.html. Here I have attached pom.xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency> <dependency> <groupId>org.springframework.boot<

Weird “Could not resolve reference: undefined Not Found” messages in Swagger UI 3

こ雲淡風輕ζ 提交于 2021-01-28 11:54:53
问题 While migrating Alfresco's REST API Explorer from Swagger UI 2 to Swagger UI 3 (3.38.0), a single API definition raised two Could not resolve reference: undefined Not Found errors at : paths./search.post.parameters.0.schema.properties.pivots.items.properties.pivots.items.$ref and paths./search.post.responses.200.schema.properties.list.properties.context.properties.request.properties.pivots.items.properties.pivots.items.$ref All the API definitions were working fine in Swagger UI 2 All the API