swagger-2.0

Convert JSON to JSON Schema draft 4 compatible with Swagger 2.0

不羁的心 提交于 2019-11-29 05:57:53
I've been given some JSON files generated by a REST API with plenty of properties. I've created a Swagger 2.0 definition for this API and need to give it the corresponding schema for the response. The main problem: this JSON file has loads of properties. It would take so much time and I would make many mistakes if I write the schema manually. And it’s not the only API I need to describe. I know there are some tools to convert JSON to JSON schemas but, if I’m not mistaken, Swagger only has $refs to other objects definitions thus only has one level whereas the tools I’ve found only produce tree

Swagger; specify two responses with same code based on optional parameter

天涯浪子 提交于 2019-11-29 05:28:25
This question is not a duplicate of ( Swagger - Specify Optional Object Property or Multiple Responses ) because that OP was trying to return a 200 or a 400. I have a GET with an optional parameter; e.g., GET /endpoint?selector=foo . I want to return a 200 whose schema is different based on whether the parameter was passed, e.g.,: GET /endpoint -> {200, schema_1} GET /endpoint?selector=blah -> {200, schema_2} In the yaml, I tried having two 200 codes, but the viewer squashes them down as if I only specified one. Is there a way to do this? Edit: the following seems related: https://github.com

Configuring Swagger UI with Spring Boot

半世苍凉 提交于 2019-11-29 04:39:41
I am trying to configure Swagger UI with my Spring boot application. Although the v2/api-docs seems to be loading properly, the http://localhost:8080/swagger-ui.html does not load my annotated REST API. Here is what I have: pom.xml: ... <!--Swagger UI--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.4.0</version> </dependency> ... SwaggerConfig.java import org.springframework.context.annotation.Bean; import org

Array of objects as an input parameter in swagger

↘锁芯ラ 提交于 2019-11-29 02:40:20
I'm trying to describe the following post parameter in swagger: { "sources": [ { "id": 101, "parentId": 201 },{ "id": 102, "parentId": 201 },{ "id": 102, "parentId": 202 } ], "destinationId": 301, "param1": "value 1", "param2": "value 2", } The issue is that the sources is an array of objects, that swagger does not seem to support. Here is what I tried: paths: /bulk-action: post: parameters: - name: sources in: formData type: array enum: $ref: '#/definitions/BulkSource' - name: destinationId in: formData type: integer - name: param1 in: formData type: string - name: param2 in: formData type:

Using @RequestParam annotated method with swagger ui

我怕爱的太早我们不能终老 提交于 2019-11-28 23:06:19
I am using Springfox libraries to generate documentation for REST service and display it in Swagger UI. I followed the directions in Springfox documentation . I have one controller, which uses parameters from query string and the method is mapped as following: @ApiOperation(value = "") @RequestMapping(method = GET, value = "/customcollection/{id}/data") public Iterable<CustomeType> getData(@ApiParam(value = "The identifier of the time series.") @PathVariable String id, @ApiParam(name = "startDate", value = "start date", defaultValue = "") @RequestParam("startDate") String startDate, @ApiParam

How to format Swagger 2.0 text descriptions?

独自空忆成欢 提交于 2019-11-28 22:43:34
I would like to format my Swagger API descriptions so that they are not simple paragraphs of text. Preferably, I'd like to add a small table to it. I did not find an online reference about text formatting in Swagger descriptions. If I launch the Swagger Editor , and open the Instagram example (File \ Open Example \ Instagram.yaml), I see the the first description in the yaml file shows some formatting including a hyperlink and bounding box: [registered your client](http://instagram.com/developer/register/) it's easy to start requesting data from Instagram. ``` https://api.instagram.com/v1

How to open local files in Swagger-UI

£可爱£侵袭症+ 提交于 2019-11-28 16:37:15
问题 I'm trying to open my self generated swagger specification file my.json with swagger-ui on my local computer. So I downloaded the latest tag v2.1.8-M1 and extracted the zip. Then I went inside the sub folder dist and copied the file my.json into it. Now I opened the index.html and want to explore my.json . And here the problem begins: If I enter a local path, it always will be prefixed by the current url containing the index.html . And therefor I can't open my file. I tried all following

How to break swagger 2.0 JSON file into multiple modules

非 Y 不嫁゛ 提交于 2019-11-28 15:48:25
I'm trying to break my API document up into multiple JSON files that can be edited independently. All the examples I've been able to find use the Swagger 1.2 schema which has a "api":{} object for breaking it down. That appears to be missing from the 2.0 schema ( http://json.schemastore.org/swagger-2.0 ). All that defines is a single "paths" array where it bundles all the API endpoints into that single array. The effect of this in the swagger-ui is there is a single "default" category that everything gets bundled into and no way that I can tell to split it up. TLDR: How do you split operations

Ho to add multiple example items on swagger

那年仲夏 提交于 2019-11-28 13:07:04
问题 Need help on how to do this on swagger. @SWG\Property(property="LineItems", type="array", @SWG\Items(ref="#/definitions/LineItem")) @SWG\Definition( definition="LineItem", required={"Description","Quantity","UnitAmount"}, @SWG\Property(property="Description", type="string", example="Item 1"), @SWG\Property(property="Quantity", type="integer", example=100), @SWG\Property(property="UnitAmount", type="float", example=11) ) @SWG\Definition( definition="LineItem2", required={"Description",

Swagger schema properties ignored when using $ref - why?

青春壹個敷衍的年華 提交于 2019-11-28 12:39:58
I'm trying to build a Swagger model for a time interval, using a simple string to store the time (I know that there is also datetime): definitions: Time: type: string description: Time in 24 hour format "hh:mm". TimeInterval: type: object properties: lowerBound: $ref: "#/definitions/Time" description: Lower bound on the time interval. default: "00:00" upperBound: $ref: "#/definitions/Time" description: Upper bound on the time interval. default: "24:00" For some reason the generated HTML does not show the lowerBound and upperBound "description", but only the original Time "description". This