swagger

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

OpenApi required property in nested objects not working

断了今生、忘了曾经 提交于 2021-02-07 06:44:06
问题 I need to describe an api having in request body an object with required fields and one of these fields it's an object itself having another set of required fields. I'm using open api v3 and swagger editor (https://editor.swagger.io/) After i put my .yaml file onto the editor I generate an html client (> generate client > html). Then I open the static page index.html generated in the .zip file obtaning this schema: Table of Contents body secureoauthservicesv2Nested_nestedobj body id Integer

How to display required user roles (access control information) in Swagger UI for Spring's endpoints?

匆匆过客 提交于 2021-02-07 06:26:05
问题 I have a rest api made in Spring and am using Swagger for documentation. Recently a token based authentication was implemented. In the token, there are (internal) user's roles (authorities). Each controller is annotated with a couple of Swagger annotations and a @PreAuthorize(some roles..) like so: @ApiOperation("Delete user") @ApiResponses(value = { @ApiResponse(code = 404, message = "User not found", response = ErrorResponse.class) }) @PreAuthorize("hasAuthority('ADMIN')") @DeleteMapping

In Swagger UI, how can I remove the padlock icon from “anonymous” methods?

﹥>﹥吖頭↗ 提交于 2021-02-07 02:49:32
问题 I'm creating an API with .Net Core 2.1 and using JSON Web Token (JWT) for authentication. I have 2 controllers: AuthenticationController and UserController . I have decorated AuthenticationController with [AllowAnonymous] and UserController with [Authorize] . Swagger is working correctly: it allows me to hit the endpoints in AuthenticationController (SignUp/SignIn) without requesting authorization, and it does request JWT to hit the endpoints in UserController . However, in Swagger UI, every

springdoc-openapi apply default global SecurityScheme possible?

谁都会走 提交于 2021-02-06 10:11:54
问题 I have the following SecurityScheme definition using springdoc-openapi for java SpringBoot RESTful app: @Bean public OpenAPI customOpenAPI() { return new OpenAPI() .components(new Components().addSecuritySchemes("bearer-jwt", new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT") .in(SecurityScheme.In.HEADER).name("Authorization"))) .info(new Info().title("App API").version("snapshot")); } Is it possible to apply it globally to all paths, without having to go

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

Setting Customized Example for @ApiResponse

与世无争的帅哥 提交于 2021-02-04 08:31:45
问题 I am facing issue with example in response. @ApiResponse(code=200, message="fetch list of Service/Config Resources", response = testing.class, responseContainer = "List", examples=@Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON_VALUE, value = "{testingId: 1234, testingName = Testing Name}" ) ) ) But getting response example as [ { "testingId": "string", "testingName": "string" } ] 来源: https://stackoverflow.com/questions/60484171/setting-customized-example-for

Setting Customized Example for @ApiResponse

坚强是说给别人听的谎言 提交于 2021-02-04 08:31:30
问题 I am facing issue with example in response. @ApiResponse(code=200, message="fetch list of Service/Config Resources", response = testing.class, responseContainer = "List", examples=@Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON_VALUE, value = "{testingId: 1234, testingName = Testing Name}" ) ) ) But getting response example as [ { "testingId": "string", "testingName": "string" } ] 来源: https://stackoverflow.com/questions/60484171/setting-customized-example-for

向net core 3.0进击——Swagger的改变

谁都会走 提交于 2021-02-02 05:56:56
[toc] 前言 十一小长假在不知不觉间可都没了,在这个小尾巴的空隙,把这两天鼓捣的net core 3.0升级过程记录一下,首先还是根据之前的顺序一个个补充进来,先从Swagger的变化说起(新建工程什么的不多说了,就是选择的时候选3.0就可以了,2019新版更新后创建默认都是3.0)。 引入 按之前的习惯,对于引入我是不会多说,一个链接(我自己之前引入那些截图)就给大家了,但是因为3.0属于比较新的版本,所以在引入的时候,有些注意点还是要标注下的。 在3.0中,我们会在Startup这里发现,Mvc没了统一替换成Controllers,当然这并不影响我们使用,但是最关键的,我们用来实验的 Values 木得了,取而代之的是一个挺不错的api的WeatherForecast接口 引入之后,我们还复制我们之前的swagger配置内容来试试,会发现新版也针对类名,属性做了雪微的调整,这里直接一张图就可以看到。 #region Swagger services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Version = "v1.1.0", Title = "ERP WebAPI", Description = "后台框架", Contact = new OpenApiContact()