swagger-2.0

SwashBuckle/Swagger - OAuth Resource Owner Password Flow

有些话、适合烂在心里 提交于 2019-11-28 00:49:19
问题 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

Swagger: Reusing an enum definition as query parameter

我是研究僧i 提交于 2019-11-27 23:41:20
I would like to use an enum defined in definitions as part of my parameter definitions in a query string. I'm defining the Swagger Enum in the definitions part of my Swagger 2.0 spec file. OperationType: type: string enum: - registration - renewal I can create references to it in other definitions: Operation: type: object properties: name: type: string type: $ref: '#/definitions/OperationType' I can use the schema tag to make a reference to it when the parameter is in: body , but not when it's in: query - name: operation in: body description: description schema: $ref: '#/definitions

Swagger complex response model with dynamic key value hash maps

℡╲_俬逩灬. 提交于 2019-11-27 20:41:08
I'm struggling with the syntax of swagger to describe a response type. What I'm trying to model is a hash map with dynamic keys and values. This is needed to allow a localization. The languages may vary, but english should always be provided. The response would look like this in JSON: { id: "1234", name: { en: "english text", de: "Deutscher Text" } } My first try was looking like that, but I have no idea how to write the part for the name. AdditionalProperties seems to be a key, but I can't wrap my head around it. Also the requirement for english text is a mystery to me in this syntax and the

Swagger-Editor model array with distinct types

这一生的挚爱 提交于 2019-11-27 19:34:14
问题 I have a return type which is an array of two elements. The first element is an integer and the second element is an array of dictionary with keys of sql_ident and name . The sql_ident value is an integer and the name value is a string. I can't figure out how to model this in my response object. So it'd be like: [ 12, [ { "sql_ident" : 17, "name" : "Billy Bob" }, { "sql_ident" : 935, "name" : "Tina Turner" } ] ] 回答1: In OpenAPI/Swagger 2.0, array items must be of the same type, so there is no

Configuring Swagger UI with Spring Boot

南笙酒味 提交于 2019-11-27 18:42:26
问题 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

How to configure Spring Security to allow Swagger URL to be accessed without authentication

亡梦爱人 提交于 2019-11-27 16:59:41
My project has Spring Security. Main issue: Not able to access swagger URL at http://localhost:8080/api/v2/api-docs . It says Missing or invalid Authorization header. Screenshot of the browser window My pom.xml has the following entries <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.4.0</version> </dependency> SwaggerConfig : @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() {

How to create different element types within Swagger 2.0 editor

蹲街弑〆低调 提交于 2019-11-27 16:20:58
I trying to map below JSON to Swagger YAML in swagger editor 2.0 and I am not sure how to set mixed array types into my schema { "obj1": [ "string data", 1 ] } Now, my swagger definition has, schema: object1: type: array items: type: string Helen The answer depends on which version of the OpenAPI Specification you use. OpenAPI 2.0 OpenAPI 2.0 (Swagger 2.0) does not really support mixed-type array and parameters. The most you can do is to use a typeless schema {} for items , which means the items can be anything (except null ) – numbers, objects, strings, etc. You cannot specify the exact types

Defining an API with swagger: GET call that uses JSON in parameters

牧云@^-^@ 提交于 2019-11-27 15:19:30
I am trying to create a proper, REST API, and document it with Swagger (2.0). So, I have an API call that is a query, ie, it makes no changes and doesn't create anything (idempotent and safe). But it requires passing in a complex JSON parameter (list of items, 2 or 3 sets of addresses, etc). So I'm doing a GET with a parameter thats URL encoded JSON. That seems like the proper way to do it. I see so often API's like this where they do it as a POST for this reason, but that's an incorrect use of the POST verb. I'm seeing lots of swagger API's that do this... I can't figure out if there's a way

Remove Basic Error Controller In SpringFox SwaggerUI

孤人 提交于 2019-11-27 15:02:49
Is there a way i can remove the "basic-error-controller" from springfox swagger-ui? Picture: You can restrict the request handler selector to scan only the package of your project: return new Docket( DocumentationType.SWAGGER_2) .select() .apis( RequestHandlerSelectors.basePackage( "your package" ) ) ... It can be done using Predicates.not() . @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .paths(Predicates.not(PathSelectors.regex("/error.*"))) .build(); } I think, the most elegant solution

Swagger/OpenAPI - use $ref to pass a reusable defined parameter

微笑、不失礼 提交于 2019-11-27 11:37:51
Let's say I've got a parameter like limit . This one gets used all over the place and it's a pain to have to change it everywhere if I need to update it: parameters: - name: limit in: query description: Limits the number of returned results required: false type: number format: int32 Can I use $ref to define this elsewhere and make it reusable? I came across this ticket which suggests that someone wants to change or improve feature, but I can't tell if it already exists today or not? Ron This feature already exists in Swagger 2.0. The linked ticket talks about some specific mechanics of it