swagger-2.0

How to open local files in Swagger-UI

人盡茶涼 提交于 2019-11-29 20:34:37
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 combinations without success: my.json leads to file:///D:/swagger-ui/dist/index.html/my.json file:///D:

Customizing Request Header description in Swagger UI using Springfox-Swagger2

╄→гoц情女王★ 提交于 2019-11-29 19:49:21
问题 I am using Springfox Swagger2 version 2.4.0, Springfox Swagger UI version 2.4.0 and Swagger Annotations version 1.5.0 in my Spring Boot application. The question here is, I am able to generate swagger UI for my controller's API and I am able to test the same. But I am not able to specify request header description for my request header. I m using @RequestHeader annotation for the same. The code snippet in my controller API is follows: @RequestHeader(name = "Api-Key") String apiKey The Swagger

Swagger UI not sending array correctly

余生颓废 提交于 2019-11-29 17:05:28
I am trying to send multiple values (an array) (refer to on line 93 in spec ->... name: recipients[] ...) The problem I am facing is the Swagger-ui call the endpoints as below: Actual recipients[]=value1%2Cvalue2 Expected recipients[]=value1&recipients[]=value2 The %2C means , (comma). Below are the required details swagger-ui version 2.1.1 Below is the link for content of the swagger spec file reproducing the issue: http://pastebin.com/V3ZuCjVz It looks like the way to specify this is to add collectionFormat: multi - name: recipients[] in: formData description: Email addresses for recipients

Can I create a stub swagger model definition from a json file

南楼画角 提交于 2019-11-29 16:56:21
Is there a tool that lets me generate a Swagger yaml definition model from sample JSON? I would go in and and edit and clean up the yaml, but would be nice if there was something out there that would stub out the structure of a yaml based on a large or complex sample json object. You can use Apigee's API Studio that has this feature: http://apistudio.io/ Click on Insert menu and then New Model . Form a JSON example you can create all of the paths and operations you want. 来源: https://stackoverflow.com/questions/36774452/can-i-create-a-stub-swagger-model-definition-from-a-json-file

Swagger Editor shows the “Schema error: should NOT have additional properties” error for a path parameter

丶灬走出姿态 提交于 2019-11-29 16:28:38
问题 I'm using http://editor.swagger.io to design an API and I get an error which I don't know how to address: Schema error at paths['/employees/{employeeId}/roles'].get.parameters[0] should NOT have additional properties additionalProperty: type, format, name, in, description Jump to line 24 I have other endpoints defined in a similar way, and don't get this error. I wondered if I had some issue with indentation or unclosed quotes, but that doesn't seem to be the case. Google also did not seem to

Swagger: take one or more values from enum

本秂侑毒 提交于 2019-11-29 16:18:47
I am working on a swagger file, where a query parameter can take none, or n values. How can I write this in Swagger Yaml? The url I give: /sort=field1,field2 The parameter declared in swagger file - name: sort in: query schema: type: string enum: [field1,field2,field3] allowEmptyValue: true required: false description: Sort the results by attributes. (See http://jsonapi.org/format/1.1/#fetching-sorting) Have a nice day/night. A query parameter containing a comma-separated list of values is defined as an array . If the values are predefined, then it's an array of enum . By default, an array may

Swagger 2.0: Multiple Path objects with different paths but same request and response

家住魔仙堡 提交于 2019-11-29 14:21:10
Due to some backward compatibility reasons, I need to support both the paths /ab and /a-b. The request and response objects are going to be the same for both of the paths. Can I have something like the following in my swagger spec so that I do not have to repeat the request and response object definitions for both the paths. paths: /ab: /a-b: post: ... Yes, you can have a path item reference another path item, like this: paths: /ab: ... /a-b: $ref: '#/paths/~1ab' Here, ~1ab is an escaped version of /ab . In JSON pointers, there are two special characters that need to be escaped to be

Why error in Angular 5 as : has no exported member 'OpaqueToken'.?

假如想象 提交于 2019-11-29 11:51:22
I have an Angular 4 application, which I am upgrading to Angular 5. I am getting the following error. ERROR in src/app/application/services/generated/variables.ts(1,10): error TS2305: Module '"..../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'. Code snippet is : import { OpaqueToken } from '@angular/core'; export const BASE_PATH = new OpaqueToken('basePath'); export const COLLECTION_FORMATS = { 'csv': ',', 'tsv': ' ', 'ssv': ' ', 'pipes': '|' } This code is been generated by swagger editor . The OpaqueToken got removed. You have to use the InjectionToken instead. I am

Data annotations in Swagger

五迷三道 提交于 2019-11-29 09:15:41
I am using ASP.NET and Swagger that exposes a complex type that accepts a POST. It has a number of string fields that have different restricted lengths. How can I reflect that in the Swagger UI? You can annotate the properties with the StringLengthAttribute from System.ComponentModel.DataAnnotations . For instance: [StringLength(10)] public String Name {get;set;} will become: "name": { "minLength": 0, "maxLength": 10, "type": "string" } And this: [StringLength(10, MinimumLength = 5)] public String Name {get;set;} becomes: "name": { "minLength": 5, "maxLength": 10, "type": "string" } Besides

SwashBuckle/Swagger - OAuth Resource Owner Password Flow

♀尐吖头ヾ 提交于 2019-11-29 07:23:04
I'm trying to implement swagger into my Asp.Net Web API, and i'm running into a problem. I'm using the password resource owner flow, and i'm having to add a work around in order to do this, which is covered in the following stack overflow question :- Swagger/Swashbuckle: OAuth2 with Resource Owner Password Credentials Grant I've got everything working, the Bearer token is added via javascript to the request header in the current browser window, but the api calls to the controller methods requiring authorization are still return "401 - Authorization Failed". Here is the JavaScript that gets the