swagger-2.0

.NET Core 2 and SwashBuckle Swagger UI is not Displaying

限于喜欢 提交于 2019-12-09 16:35:42
问题 I have followed a few tutorials and have gotten this to work at work but for some reason I am not able to get the UI to display but the Swagger Json is created. Last tutorial I looked at is here. My setup is like so: Nuget Package: Swashbuckle.AspNetCore(1.0.0) ConfigureServices Method: services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "MediatR Example", Version = "v1", Description = "Trying out the MediatR library to simplify Request and Response logic.",

How to DRY when using Swagger UI and the ApiResponses annotations with Java Spring endpoints?

别等时光非礼了梦想. 提交于 2019-12-09 15:03:04
问题 I like Swagger because it makes your apis very user friendly. I use Swagger annotations like @ApiParam @ApiResponse | @ApiResponses @ApiOperation Others On endpoints, query params, request params, request body and so on. I like to keep my POJO classes clean and in general I try my best to follow DRY rule however, when it comes to swagger I noticed that I keep repeating myself over and over as shown below @ApiOperation(value = "Retrieve object by id") @ApiResponses(value = { @ApiResponse(code

Best practice to send response in spring boot

强颜欢笑 提交于 2019-12-09 01:33:17
问题 I'm coding REST Api-s in spring boot. I want to make sure that my code is readable to front-end developers using swagger API development tool (Swagger). For example @GetMapping("/getOne") public ResponseEntity<?> getOne(@RequestParam String id) { try { return new ResponseEntity<Branch>(branchService.getOne(id), HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<FindError>(new FindError(e.getMessage()), HttpStatus.BAD_REQUEST); } } If the request is successful, response is a

Java 8 LocalDate displaying in swagger

醉酒当歌 提交于 2019-12-08 12:02:35
问题 I have a DTO which contains field of Java 8 LocalDate type. With Jackson annotations it's possible to set format to ISO.DATE and everything works good. But Swagger (I have version 2.+) see the LocalDate.class as object LocalDate { month (integer, optional), year (integer, optional) } (That's true but...) I want to dipsay this as string with format as it works with util.Date . How can I solve it? 回答1: I was facing same problem, so I added @Bean public Docket docket() { return new Docket

Swagger2 > Document a SpringBoot MvcEndpoint

送分小仙女□ 提交于 2019-12-07 18:10:04
问题 I'm currently in the process of trying out Swagger2 on my SpringBoot project (it works great), however, it only picks up my @RestController classes. I was wondering: Can it be used to pick up a Spring-Actuator MvcEndpoint? Can the Swagger2 components (e.g. /swagger-ui.html , /v2/api-docs ) be hosted under the management port (e.g. http://${management.address}:${management.port}), instead of server.port ? Application.java @EnableSwagger2 @SpringBootApplication public class Application { @Bean

Require array to contain at least one element in Swagger Schema Object definition

泪湿孤枕 提交于 2019-12-06 19:33:01
问题 I'm having a Schema Object definition like this in my swagger.yaml : User: type: object properties: username: type: string description: the user name colors: type: array items: { type: string, enum: [ "red", "blue", "green" ] } description: user must have one or more colors associated required: - username - colors However, the generated server still happily accepts POST requests using this schema object as required body parameter that do not contain any colors field. Can I configure Swagger

How to define HashMap<String, List<Object>> property in swagger yml?

北城以北 提交于 2019-12-06 08:14:06
问题 I am using swagger to generate classes in Java and Type script. I have problem defining map property with list of objects as value. I tried to define as follows: DataMap type: object additionalProperties: #type: array -- This config does not work. $ref: '#/definitions/Data' Above yml definition generated following code in java: class DataMap extends HashMap<String, Data> { } How can I configure yml to generate key with list of data ? something like following class: class DataMap extends

Multiple API documentation in one Swagger file

萝らか妹 提交于 2019-12-06 07:58:37
问题 Is it possible to have multiple (somehow separated) REST API documentations but only in one swagger yaml file? Or can the swagger yaml contain only one API documentation? Because I have 2 REST API developed by me, and I want to have a common swagger ui instead of two, which I could manage with a gateway like Tyk. 来源: https://stackoverflow.com/questions/51080805/multiple-api-documentation-in-one-swagger-file

Swagger UI empty and gives 403

为君一笑 提交于 2019-12-06 06:01:34
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() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } } When I go this url: http:/

Swagger 2 accept xml instead of json

霸气de小男生 提交于 2019-12-06 05:51:52
问题 I have a project with spring boot and I want to use swagger2 to document my json web services. I have this configuration : @Configuration @EnableSwagger2 public class Swagger2Config { @Bean public Docket welcomeMessageApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("My API") .description("Lorem Ipsum is simply dummy