swagger

Combine multiple annotations into one to avoid repeating them

孤街浪徒 提交于 2019-12-07 01:22:39
问题 I'm working on the implementation of various REST services, using Spring MVC. For documentation, I'm using Swagger. This works nice and the documentation looks good and is really functional. The only problem I have is that the annotations for documentation really crowd the controller classes, especially the error code annotations. Example: @ApiErrors(value = { @ApiError(code = 123, reason = "Reason123"), @ApiError(code = 124, reason = "Reason124"), @ApiError(code = 125, reason = "Reason125"),

what is the proper way to create a swagger web service in TypeScript

对着背影说爱祢 提交于 2019-12-07 01:04:18
问题 I am part of a project written in TypeScipt and I am trying to add TypeScript Web Server which will be compatible with Swagger. What is the most basic strategy to implement it, considering easy maintainability. For Typescript I have notice that exists 'Typson' library for generating a JSON Model from TypeScript Interface. For Swagger, I have tried using 'swagger-node-restify' library, since it supports adding JSON models to swagger. However, I encounter some problems: Typson doesn't support

Swagger: Add description with ref

孤者浪人 提交于 2019-12-06 21:25:56
问题 I want to add a description to an object property that his definition is referenced. Something like that: newCreditCard: type: object properties: billingPhone: description: Phone number of the card holder $ref: "#/definitions/PhoneNumber" But the editor warns that the description property will be skipped: Extra JSON Reference properties will be ignored: description I have found a less elegant workaround that works for the editor, but not for the Swagger UI (not sure that is may due to the

Tell Swagger that the request body can be a single object or a list of objects

流过昼夜 提交于 2019-12-06 20:26:14
问题 I am using Swagger with Scala to document my REST API. I want to enable bulk operations for POST, PUT and DELETE and want the same route to accept either a single object or a collection of objects as body content. Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type A? Something like varargs for REST. 回答1: Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type A? This depends on whether

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

微信公众号模板推送

此生再无相见时 提交于 2019-12-06 18:57:18
公众号推送消息是十分重要又基础的功能,这里主要记录一下微信公众号推送模板开发的相关流程和代码。 首先:要申请模板消息功能,选择主营行业和副营行业,并输入申请理由(相应的例子网上一大堆,这里不赘述了); 申请完了之后就感觉你选择的行业去模板库里面找类似需要的模板类型,模板库其实还是蛮全的,实在没有找到也可以自己申请新的模板,不过每个月有上限; 先上代码: 先选择一个模板(这里放一个简单的模板): {{first.DATA}} 退款原因:{{reason.DATA}} 退款金额:{{refund.DATA}} {{remark.DATA}} 原理就是按照模板的数据格式往里面传值,具体情况看代码 结果是这样的: controller: import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import com

Does django-rest-swagger not work well with modelserializers?

点点圈 提交于 2019-12-06 18:33:32
问题 I've been going off of the documentation on the django-rest-swagger github page, more specifically the part called "How it works". It shows that you can define your own parameters for your rest api, and have those parameters show up in your swagger doc page. The commenting example is something like: """ This text is the description for this API param1 -- A first parameter param2 -- A second parameter """ I can get this to work, but my issue is how to specify if the variable is required, its

Can I override properties of a parameter definition object when referencing it?

非 Y 不嫁゛ 提交于 2019-12-06 18:27:56
问题 I have some parameter defined in the root parameters parameters: fooParam: name: foo in: query description: Foo foo foo. required: false type: number format: int32 Now I reference it in a path /pathOne: get: parameters: - $ref: "#/parameters/fooParam" Let say I want to use that parameter in another path or method, but I want it to be required (required: true) /pathTwo: get: parameters: - ????????????????? Is there a way to reference the same parameter and override one or more of its

Is there a way to automatically generate Swagger tags from precomipled C# Azure Functions?

夙愿已清 提交于 2019-12-06 14:28:08
问题 Is anyone aware of any .NET attributes that can be used to annotate a precompiled C# Azure Function so it can generate Swagger tags automatically? For example, I would like to auto-generate the "tags" entry in Swagger: /api/v1/revision: get: operationId: /api/v1/revision/get tags: - System produces: [] consumes: [] parameters: [] description: Gets the API version responses: '200': description: Success operation security: - apikeyQuery: [] Here is my C# function: public static class

How to tell Swagger an attribute is a Map

帅比萌擦擦* 提交于 2019-12-06 13:32:25
问题 I am developing a restful service with Jersey. However, I am using Swagger for documentation. My Model has a property with Type of Map. Swagger shows that this attribute as an Object (not a specific type). So how can I tell Swagger that this property is from type Map ? public class Model { private String name; private Map<Integer, String> myMap; public Model(){ super(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public Map<Integer, String