swagger

Swagger ApiModelProperty not working

℡╲_俬逩灬. 提交于 2019-12-24 14:00:26
问题 I have a problem with @ApiModelProperty in swagger. In my model, I use @ApiModelProperty like this private static final long serialVersionUID = -7142106197262010406L; private int brandId; private String brandName; private String fullName; private String webSite; private String logoUrl; private String note; @ApiModelProperty(position = 1, required = true, value="") public int getBrandId() { return brandId; } public void setBrandId(int brandId) { this.brandId = brandId; } @ApiModelProperty

How Can I add basic auth in swagger 3.0 automatically with out the user to type in at authorize button?

前提是你 提交于 2019-12-24 12:00:38
问题 I am using swagger 3.0 and have multiple endpoints in swagger docs. I want user not to type in credentials at authorize button every time. Is there any way I can include authentication in index.html or in my yaml files to automatically authorize the user. Thanks. 回答1: Swagger UI 3.13.0+ provides the preauthorizeBasic method for this purpose. Assuming your API definition includes a security scheme for Basic auth: swagger: '2.0' ... securityDefinitions: basicAuth: type: basic security: -

Getting swagger-core 1.5 to work with Jersey and Grizzly

十年热恋 提交于 2019-12-24 11:51:46
问题 I have a Jersey2 application that runs on an embedded Grizzly server - a setup identical to this example: https://github.com/jersey/jersey/tree/2.18/examples/https-clientserver-grizzly/src/main/java/org/glassfish/jersey/examples/httpsclientservergrizzly I have integrated it with swagger-jersey2-jaxrs_2.10 and it has been working OK. Now that swagger-core 1.5 came out and it produces Swagger 2.0 definitions, I would like to upgrade to that version. Having followed the Swagger setup

Open API inherited example data

馋奶兔 提交于 2019-12-24 11:37:50
问题 I'm using OpenAPI 3.0 to define an API for a service I am building. I'm running into an issue reusing schema components inside other components. For example, I have a Note object which contains a Profile object of the person who created the note. This works as expected by referencing the Profile object using the $ref keyword. The issue is when showing the example there isn't any data for the profile, and if I place the ref in the example like below it includes the actual OpenAPI block of

Returning an array of objects that properly defines the SDK response

℡╲_俬逩灬. 提交于 2019-12-24 10:58:06
问题 I have a typical RESTful endpoint that returns a collection of models, but the generated Ruby SDK returns a new model, Matters instead of an array of models. I can hack at the generated source code to return Array<Matter> but that is a maintenance headache. How do I specify that I want to return Array<Matter> in the YAML? paths: /matters: get: ... responses: 200: schema: $ref: "#/definitions/Matters" ... definitions: Matter: type: "object" properties: id: type: "string" description: "Database

Define common swagger annotation

China☆狼群 提交于 2019-12-24 09:48:45
问题 Admittedly, I didn't look too hard for an answer. My question is, when defining swagger annotations using springfox-swagger-ui , how does one define common ApiResponse used for more then one method and potentially more then one class? See the 2 sample methods below the common ApiResponse is error 500. Ideally, I would want to define that once. Any best practices and/or suggestions? Sample code below: @GET @Path("/greeting") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Returns

.net core 添加 Swagger

社会主义新天地 提交于 2019-12-24 09:28:23
1.新建一个Core项目   添加nuget包:Swashbuckle.AspNetCore   添加Startup文件:     先引用: using Swashbuckle.AspNetCore.Swagger;     添加的配置如下: public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) {//启用中间件服务生成Swagger作为JSON终结点 app.UseSwagger(); //启用中间件服务对swagger-ui,指定Swagger JSON终结点 app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); }   这样就可以打开swagger调试接口了 https://localhost:44399/swagger/index.html 2

Servicestack object parameter not getting passed to service with Swagger-UI

烂漫一生 提交于 2019-12-24 09:08:10
问题 My service model: [Route("/customer/{CustomerId}/creditcardtoken/{CanLookup}", "POST")] public class CreditCardToken : IReturn<CreditCardTokenResponse> { [ApiMember(ParameterType = "path", DataType = "string", IsRequired = true, Verb = "POST")] public string CustomerId { get; set; } [ApiMember(ParameterType = "path", DataType = "boolean", IsRequired = true, Verb = "POST")] public bool CanLookup { get; set; } [ApiMember(ParameterType = "body", DataType = "CreditCard", IsRequired = true, Verb =

Swagger2怎么整合OAuth2来在线调试接口?

孤街醉人 提交于 2019-12-24 08:42:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 知识改变命运,撸码使我快乐,2019年你的发迹线还好吗?<br/> 点赞再看,养成习惯<br/> 本篇文章对应源码码云(Gitee)仓库<br/> https://gitee.com/minbox-projects/api-boot-chapter ,您的Star是给我最大动力 前言 Swagger2 作为侵入式文档中比较出色的一员,支持接口认证的在线调试肯定是不在话下的,当我们在调用 OAuth2 所保护的接口时,需要将有效的 AccessToken 作为请求 Header 内 Authorization 的值时,我们才拥有了访问权限,那么我们在使用 Swagger 在线调试时该设置 AccessToken 的值呢? <!--more--> 本文所需ApiBoot相关链接: ApiBoot官网 ApiBoot全组件系列文章 ApiBoot Gitee源码仓库(欢迎Contributor) ApiBoot GitHub源码仓库(欢迎Contributor) 创建示例项目 在之前文章「 使用Swagger2作为文档来描述你的接口信息 」我们已经讲到了使用 Swagger2 来简单的描述接口,提供可视化在线的接口文档,我们本章的主要目的是来集成使用 OAuth2 实现在线调试接口,我们把之前章节测试的接口

Swagger Schema: oneOf, anyOf, allOf valid at the same time?

一世执手 提交于 2019-12-24 08:38:20
问题 I'm just reading through the more advanced validators in the Schema definition of the Swagger specification: { "Schema":{ "type":"object", "properties":{ "title":{ "type":"string" }, "multipleOf":{ "type":"number", "minimum":0, "exclusiveMinimum":true }, "maximum":{ "type":"number" }, "exclusiveMaximum":{ "type":"boolean", "default":false }, "minimum":{ "type":"number" }, "exclusiveMinimum":{ "type":"boolean", "default":false }, "maxLength":{ "type":"integer", "minimum":0 }, "minLength":{