FAQ Database Discussion Community


How to account for servlet path mapping when rendering paths for swagger service description

java,spring-mvc,java-ee,swagger,swagger-ui
I have problem with configuring swagger. When I specify link for servlet in web.xml like <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> swagger shows url-s without .../rest/... so I can't use swagger-ui for testing, when I specify url-pattern /* swagger-ui don't work. Here is configuration class @Configuration @EnableSwagger public class DocumentationController extends WebMvcConfigurerAdapter...

Can I specify the response directly in Swagger 2.0?

swagger,swagger-ui
I am defining my response as per: responses: 200: description: 'An authProvider object' schema: type: 'array' items: $ref: '#/definitions/AuthProvider' Is it possible for me to directly attach another field or 2 in the response? I would like to add something that I don't want to put into AuthProvider...

Swagger - Springfox always generates some response messages (401,403…) by default. How can I remove them?

spring-mvc,swagger,swagger-ui
I have controller as simple as this: @RequestMapping(value="/async/data", method=RequestMethod.GET, produces="application/json") @ApiOperation(value = "Gets data", notes="Gets data asynchronously") @ApiResponses([email protected](code=200, message="OK")}) public Callable<List<Data>> getData(){ return ( () -> {return dataService.loadData();} ); } I was expecting to have only a response message for HTTP status 200. However springfox always generates the ones below...

What specification should I use for documenting REST APIs?

api,rest,jax-rs,swagger,hydra
I've been looking for automatic creating the documentation for the REST API of a project I'm working on. First, Hydra (http://www.hydra-cg.com) shows up with an interesting idea for designing Web APIs. Later some colleagues recommend me to use Swagger 2.0 (http://swagger.io) as code generator. Then, I realise that both specifications...

Sails.js API documentation

node.js,model-view-controller,sails.js,swagger
I want to develop an API using the MVC pattern. I found sails framework interesting and I'd like to know if it's possible to configure swagger or something like with sails to generate the documentation of my API (something like swagger-express for express for example). Thanks!...

Validation error: Data does not match any schemas from 'oneOf'

swagger
I'm getting the error Data does not match any schemas from 'oneOf' with the following spec: { "info": { "version": "1.0.0", "title": "REST API" }, "paths": { "/doit": { "post": { "responses": { "200": { "description": "Successful response" } }, "parameters": [ { "type": "object", "schema": { "$ref": "#/definitions/ResponseDefinition" },...

Swagger is not generating @Api resources

spring,jersey,swagger
I'm trying to integrate Swagger to document my REST API. I have followed this tutorial verbatim: http://jakubstas.com/spring-jersey-swagger-configuration/ and it works peroperly. I see: { apiVersion: "1.0", swaggerVersion: "1.2" } Now, I want to register one endpoint: @Path("endpoint") @Api(value = "/endpoint", description = "My first documented endpoint") public class MyEndpoint {...

Using @JsonIgnore on my getter is making it so that my variable doesn't show up in the POST model schema either

swagger
I have the following: @JsonIgnore public String getPassword() { return password; } @JsonProperty public void setPassword(String password) { this.password = password; } What I'd like is for the swagger UI to show the password field on my POST function still as I am only hiding it from the GET call....

How to make a field in a definition required for some operations and not others

swagger,swagger-2.0,swagger-editor
I'm writing my swagger definition in yaml. Say I have a definition that looks something like this. paths: /payloads: post: summary: create a payload ... parameters: - in: body name: payload description: New payload required: true schema: $ref: "#/definitions/payload" put: summary: update a payload ... parameters: - in: body name:...

Swagger 1.2 endpoint configuration is not loading

configuration,swagger
Im new Swagger user. I created endpoint with long model definition. But when endpoint is attached to api-docs, this is not working. I checked that that endpoint configuration file is valid JSON file. How to check where is the problem with with this file? Im using Swagger 1.2....

Adding Swagger to Spring MVC project (Error creating bean)

java,spring,spring-mvc,swagger,swagger-ui
this is a very simple thing usually but I have sat with it for long and have tried multiple configurations and git repositories but can't get it to work. The errors I receive looks like this: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error...

How can I make url path in Swashbuckle/Swaggerwork when api is served from inside another project?

c#,rest,asp.net-web-api,swagger,swashbuckle
all. I am trying to document a WebApi 2 using Swashbuckle package. All works great if the API is running by itself i.e. localhost/api/swagger brings me to ui and localhost/api/swagger/docs/v1 to json. However the producation app initializes this same Webapi project by running webapiconfig method of this project from global.asax.cs...

Hapi Swagger skip certain endpoints

node.js,swagger,hapijs
Since the npm module hapi-swagger doesn't support file upload endpoints I need a way to skip certain endpoints in my tests. I've checked the docs and there's no beforeEach or any way to check which endpoint is which during the test runs. Currently I've just got my environment set to...

Swagger: support for optional routes

swagger,swashbuckle,swagger-2.0
I have a route with an optional parameter: [Route("{categoryId?}")] public HttpResponseMessage Get(int? categoryId=null) However, when I don't provide a value for categoryId the call includes {categoryId?} in the request itself... http://myhost/api/%7BcategoryId%7D ...

Automatically import REST APIs from GitHub / via API into API Manager?

import,automation,swagger,bluemix,swagger-2.0
Does the API Manager / Bluemix provide an interface (API, hook) to automatically update API definitions when I push Swagger 2.0 API definition changes to a GitHub repository?

Swagger url for self hosted servicesteack service

.net,web-services,servicestack,swagger
I am trying to use ServiceStack.Api.Swagger and by default swagger url is pre-populated with /swagger-ui/resources While for self-hosted ServiceStack service it is available right under /resources How can I change routing for self-hosted service for embedded swagger resources or update default swagger url. Routing update is preferable way as it...

Using Swashbuckle to Host an Existing Swagger.JSON file

asp.net-mvc,asp.net-web-api,swagger,swashbuckle
I have an existing Swagger.json file for a .NET WebApi site which I would like to integrate with my developer site (which is at a different url) running Swashbuckle. Can I simply copy this swagger.json file to the mvc site (content or app_data folder and do this?) If I can,...

Gulp Plugin for Validating Swagger Documents?

node.js,npm,gulp,swagger
I've decided the most logical way to maintain an enormous Swagger document is to decompose it into node modules and then have a Gulp task that builds them all together. I would however like to validate the Swagger after it's written. Is there a plugin to do this?

Multi-line literals in swagger editor?

swagger,swagger-editor
I am trying to get a multi-line literal in Swagger editor (awesome tool, by the way!). post: summary: Translate one or more identifiers description: | Translate one or more identifiers for one entity into the identifiers of another entity. Translate one or more identifiers for one entity into the identifiers...

Is There A Library of Public API Swagger Definitions? [closed]

swagger,raml
So I've been building a service that taps into popular APIs around the web and I've found Swagger to be a huge asset to the project. Instead of writing a ton of custom code that is difficult to maintain, I've been able to use Swagger definitions to dynamically create all...

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

swagger
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...

How to add multipart/mixed MIME boundary in Content-Type header in Swagger

mime-types,swagger,swagger-ui
In Swagger UI, is there a way to supply a MIME boundary that can be included in the Content-Type header? Using Swagger, I can generate / submit different content types in Swagger UI by using the consumes property in the Swagger Spec, e.g. application/json, application/xml, etc. However, I need to...

API Manager: Set API icon in Swagger 2.0 definition?

import,swagger,bluemix,swagger-2.0
Is it possible to define an API icon in the Swagger 2.0 definition that will be shown on the app developers page? Or is it at least possible to set an API icon in the API Manager UI? I could not find anything related. ...

Swagger SpringMVC Integration (Failed to load @PostConstruct method)

spring,api,spring-mvc,swagger
I am trying to integrate swagger-springmvc 0.9.5 with SpringMVC 3.2 project with XML configuration. My app-config.xml: <beans xmlns="ht... <context:annotation-config /> <mvc:annotation-driven> <mvc:message-converters> <bean id="messageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" /> </mvc:message-converters> </mvc:annotation-driven> <context:component-scan base-package="com.myapp.info.v1.rest.endpoint"/> <bean...

Why won't my swagger PUT or POST?

swagger,swagger-ui
I am using Swagger 2.0 and my definition is: { "/users/{UserId}": { "get": { "summary": "Get a specific user by id", "description": "", "parameters": [{ "name": "UserId", "in": "path", "description": "Id of the User.", "required": true, "type": "string" }], "tags": [ "Users" ], "responses": { "200": { "description": "An specific...

How to send Authorization header with a request in Swagger UI?

swagger,swagger-ui,swashbuckle,swagger-2.0
I have a ASP.NET Web Api 2 application. I added Swashbuckle to it (Swagger for .NET). It displays my endpoints no problem, but in order to send a request I need to attach an Authorization header to that request. If I understand correctly in order to do that I need...

Populate API Manager “Documentation and Attachments” tab from Swagger 2.0 definition?

swagger,bluemix,swagger-2.0
How do I specify items for the "Documentation and Attachments" tab in the API Manager in my Swagger 2.0 definition? ...

Swagger APIs array is empty for SpringMVC app

java,spring,spring-mvc,gradle,swagger
I setup Swagger for my Spring MVC project as described in Swagger-springmvc README. I use Spring Java Configuration not XML-based Spring configuration. As build system I use Gradle. When I perform GET request to api-docs I get following JSON {"apiVersion":"1.0","apis":[],"authorizations":{},"info":{"contact":"My Apps API Contact Email","description":"My Apps API Description","license":"My Apps API Licence...

swagger generation in mule with jetty

java,jetty,mule,swagger
I am trying to generate swagger from my apis.I am using mule and added this jetty connector for that. My mule server is running on 8080 <jetty:connector name="jettyConnector"> <jetty:webapps directory="${app.home}/webapps" port="8083"/> </jetty:connector> I have added web .xml under src/main/app/webapps/swaggerdoc/WEB-INF/web.xml and the content is: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...

Bluemix API Manager Swagger 2.0 import ignores “formData” variables

import,integration,swagger,bluemix,swagger-2.0
In this code, path and query variables are imported, but the form data variable is not. However, (non-IBM) Swagger UI displays it correctly. { ... "paths": { "/stuff/{p}": { "post": { "consumes": [ "application/x-www-form-urlencoded", "multipart/form-data" ], "parameters": [ { "name": "p", "in": "path", "description": "Path variable", "required": true, "type": "string"...

Swagger UI for messaging API

swagger,swagger-ui,swagger-editor
I'd like to know if the following is possible. Swagger is almost what I need to document a Message based API. For instance for a Command Message I'd like to say "Command" instead of "Post", and instead of "path" I'd like to have the name of the Command. The spec...

Document @ApiOperation with long detailed description

jax-rs,swagger,swagger-ui
While documenting an operation using @ApiOperation, there is the notes atribute for a long description of the operation. But putting a long description in the annotation makes it cumbersome and difficult to mantain. Is there a more elegant option to reference an external file or something?...

How do I define possible return values with Swagger.io

swagger,swagger-ui
I have an API call whose response includes a status field with a large number of potential status codes. These codes are numeric and thus not self-explanatory. Using Swagger.io how can I provide a table of these status codes with their corresponding description?...

Personnalize route format - Swagger with Play Framework

java,playframework,routes,swagger
I am developing an API with Swagger UI using Play Framework. But I got a little problem (not a big problem) : My URL are : https://url/find?param1=false&&&param4=1 But I have '&&' when a parameter is not given ( I mean param2 and param3) What I want is simply : https://url/find?param1=false&param4=1...

Swagger same path specified twice

swagger,swagger-ui
Is it possible to have same path appear more than once in one API spec which is being rendered by Swagger-UI? Should I create separate api specs and load two instances of Swagger-UI? What is the best way to handle this? For ex. I have endpoint called /oauth/token which I...

Swagger UI Not Displaying Any Content On index.html Page

java,spring,swagger,swagger-ui,apache-wink
UPDATED with SOLUTION below!!! ////////////////////////////////////////////////////////////// Thanks to the advice of Ron below I slightly modified my setup to use BeanConfig instead of SwaggerConfig and got this working. In order to do this I had to modify the servlet and also (and this is where I believe the missing piece was)...

Use a different JSON serializer in swagger

asp.net-web-api,swagger
I am using Swashbuckle for API documentation, works great but Swashbuckle seems to serialize objects in camel case, and I use NewtonSoft lib to serialize objects, which has an attribute [JsonProperty(name="")] and these are used during serialization. Is there a way I can customize Swashbuckle to use the same serializer...

Enabling Spring Security makes Swagger output text/plain instead of HTML

spring-security,spring-boot,swagger,swagger-ui,swagger-maven-plugin
Swagger works! I can interact with http://localhost:8090/sdoc.jsp and everything is fine. I add the following to pom.xml... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> I also add the following two files: @Component public class CustomAuthenticationProvider implements AuthenticationProvider { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String name =...

Grape-Swagger not listing methods contained in a grape-based API

ruby,swagger,grape,api-doc
I'm using the grape-swagger gem and I'm being unable to get a Grape-based API properly described in Swagger. Using: grape (0.11.0) and grape-swagger (0.10.1) When I enable the Swagger json listing I get this output listing all endpoints but not the methods contained in each endpoint. My output: { "apiVersion":...

Swagger Error Expected type string but found type integer

java,yaml,swagger
I started working recently on swagger to generate documentation for our RESTful apis. I use the yamlbeans-1.09.jar to convert my Java DTOs to a yaml file. Everything works fine and the yaml is even validated properly on the http://www.yamllint.com/ but still while testing it with the Swagger interface, it gives...

Is it possible to define a parameter set and reference it?

reference,swagger,swagger-2.0
I have multiple parameters that I want to reference, but I do not want to specify them one by one. This snippet does not make the parameters show up: { ... "paths": { "/stuff": { "get": { "description": "Gets stuff", "operationId": "getStuff", "parameters": { "$ref": "#/definitions/set1" } } } },...

Why the definitions fail to be displayed in this schema?

swagger,swagger-ui
I'm trying to develop a schema compliant with the swagger specifications. See below. The definitions(model/schema) of the Parameters and Responses are not displayed in the swagger-ui interface so my question why is that. The schema passes the swagger validator. { "swagger": "2.0", "info": { "version": "1.0.0", "title": "example", "description": "provides...

Composer fails to load fork from package

php,github,composer-php,swagger
I struggle loading a fork for a package with composer. I am trying to integrate Swaggervel, a Swagger package for Laravel 5, into my project. The current dev-master has a bug which causes incompatibility to laravel 5. BUT there is a fork on github https://github.com/mvpasarel/swagger-laravel which fixes this issue. So...

http basic auth with swashbuckle api documentation

asp.net-web-api,swagger,swashbuckle
could anyone know how could i integrate basic auth with swashbuckle api's documentation? I saw that there's a basicAuth function in the swaggerconfig file: c.BasicAuth("basic").Description("Basic HTTP Authentication"); What i've done: uncommented the previous line but nothing changed! does anyone have any idea what did i miss? Thanks!...

How to define a map in swagger?

swagger,swagger-ui
I'm working on an API which also generates swagger documentation. The issue is that for some reasons the request model/schema is not displayed in swagger UI but I don't get any error either. I need to represent map to an array of strings . e.g. map[string][]string. Definition object definition is...

Document Restful API created in Node.JS

javascript,node.js,documentation,swagger
I have created Restful APIs in Node.js and now I plan to document them so they can be shared with others. I spent the past couple of days researching in to this and I found Swagger and started exploring what it had to offer. I really like Swagger-UI, It takes...

How does this npm build work?

node.js,npm,swagger
https://github.com/apigee-127/swagger-converter I see this code: var convert = require('swagger-converter'); var fs = require('fs'); var resourceListing = JSON.parse(fs.readFileSync('/path/to/petstore/index.json').toString()); var apiDeclarations = [ JSON.parse(fs.readFileSync('/path/to/petstore/pet.json').toString()), JSON.parse(fs.readFileSync('/path/to/petstore/user.json').toString()), JSON.parse(fs.readFileSync('/path/to/petstore/store.json').toString()) ]; var swagger2Document = convert(resourceListing,...

@Api annotation description is not getting displayed

swagger,swagger-ui
I have following in my code @Path("/description") @Produces(MediaType.APPLICATION_JSON) @Api(value="description", description="Service description") public class Service{ .... } On swagger UI I am able to see description: true Instead of description: Service description Please help. What am I missing?...

How to set up Swagger with express?

coffeescript,swagger,swagger-ui
I am using the {swagger-express} library and my code is all in CoffeeScript. For my definition, I have: app.use swagger.init app, apis: ['./src/routes.coffee', './src/models.yml'] apiVersion: '0.1.0' basePath: "http://localhost:#{port}" info: title: 'My API' description: 'A complete listing of all API functions' swaggerUI: path.join __dirname, 'public' swaggerURL: '/swagger' require('./src/routes') app In routes,...

Can't get json from Swagger + Jersey

java,api,rest,jersey,swagger
I have RESTful service based on Jersey 1.18.1 and I want to show my API via Swagger. Firstly I have to get JSON. I read this instruction: Swagger Core Jersey 1.X Project Setup 1.5. Swagger allows to set up a configuration different methods and I decided to use custom Application...

Leverage MultipleApiVersions in Swagger with attribute versioning

attributes,asp.net-web-api2,swagger,swagger-ui,swashbuckle
Is it possible to leverage MultipleApiVersions in Swagger UI / Swashbuckle when using attribute routing? Specifically, I implemented versioning by: using System.Web.Http; namespace RESTServices.Controllers.v1 { [Route("api/v1/Test")] public class TestV1Controller : ApiController { ... } Version 2 would be in a v2 namespace. In a controller named TestV2Controller. The route would...

How do I change the API name in the class generated by swagger-codegen

swagger
I am using swagger-springmvc and swagger-codegen to generate a Java client library for a RESTful webservice. I have written my own extension of the BasicJavaGenerator (see below) to override the package names, and can successfully generate the client library files. The "main" files generated are: swagger-codegen/generated-code/java/pom.xml swagger-codegen/generated-code/java/src/main/java/com/example/ApiApi.java swagger-codegen/generated-code/java/src/main/java/com/example/model/*.java What I...