swagger

Swagger spitting out xml response instead of json

醉酒当歌 提交于 2019-12-11 17:34:10
问题 I'm a week old in spring. I'm developing a pure RESTful API service using Spring + maven + Jackson. While exploring some best practices, I came across this, so I decided I'll be using swagger with spring mvc (and swaggerUI) for documentation. I went through this and this tutorial for doing what I wanted. Everything was going fine and dandy until I realized after hitting /api-docs I got XML response, as opposed to JSON response in tutorials and every-other-where. This won't work fine when I

Swagger-YAML Bad Mapping entry in my products [duplicate]

邮差的信 提交于 2019-12-11 17:16:22
问题 This question already has an answer here : Swagger:Issue with Path parameter (1 answer) Closed last year . Hi guys I am having difficulties with YAML and I need your help. I am having this code and it gives me error, and i cant find where or what i am doing wrong.Error msg that i am receiving is below /product/{productid}/fabric/{fabricid}: get: tags: - "Product" summary: "Get Fabric by Id" description: "This endpoint displays Fabric details" produces: - "application/json" parameters: - name:

Integrating Swagger with Spring 3.0.6.RELEASE

折月煮酒 提交于 2019-12-11 17:13:18
问题 My current project is maven based with Spring 3.0.6.RELEASE (Spring rest) and I am trying to integrate swagger with my project but I am facing dependency issues and also not finding enough documentation from the swagger websites. I have used below dependencies in pom.xml file. <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.0.6.RELEASE</version> </dependency> <dependency> <groupId>com.mangofactory</groupId> <artifactId>swagger-springmvc<

swashbuckle mediatype application/octetstream

我怕爱的太早我们不能终老 提交于 2019-12-11 17:05:57
问题 I have an endpoint that produces mediatype as application/octet-stream. However, when I generated the swagger json, it specifies "produces" as "application/json" I did not do any special configs in swagger. All I did was import swagger nuget and just kept the default configuration as is. Please find below the endpoint: [HttpPost] [Route("document/method1")] public HttpResponseMessage method1([FromBody]SomeModel SomeModelValue) { // code that generates the file if (File.Exists(outputFilePath))

Swagger Spec Validation in Java

醉酒当歌 提交于 2019-12-11 17:05:06
问题 iam trying to validate some strings that may contain swagger specifications. Iam trying to use the swagger parser. The following code doesn't work. I only get the message: "[attribute is not of type object ]" The swagger spec is read out of an xml file. swaggerXml = nodeList.item(0).getTextContent(); SwaggerDeserializationResult res = new SwaggerParser().readWithInfo(swaggerXml); for (int i = 0; i < res.getMessages().size(); i++){ log.info(res.getMessages().toString()); } Is this method wrong

Swagger2 ui not accessbile

China☆狼群 提交于 2019-12-11 16:48:15
问题 I am using Swagger in a Spring boot application, I somehow can access most of Swagger's endpoints such as /v2/api-docs , /swagger-resources but I can't figure out why /swagger-ui.html is not accessible. I am using these dependencies: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> </dependency> here is my Swagger Config class: @Configuration

Swagger breaks when adding an API Controller to my Host Project in aspnetboilerplate

折月煮酒 提交于 2019-12-11 15:58:20
问题 I downloaded a new .Net Core MVC project template from https://aspnetboilerplate.com/Templates, setup everything (database and restored nuget packages) and ran the Host application. All good as I get the Swagger UI going and can see all the standard services. I then proceeded to create a simple API controller in the Host application: [Route("api/[controller]")] [ApiController] public class FooBarController : MyAppControllerBase { public string HelloWorld() { return"Hello, World!"; } } And

Swagger-Net supporting API Key authentication

筅森魡賤 提交于 2019-12-11 15:54:19
问题 We are using token authentication in our WebAPI application. Every call (other then method which obtains key) uses same pattern. Authorization: our-token v01544b7dce-95c1-4406-ad4d-b29202d0776c We implemented authentication using Attribute and IActionFilter Controllers look like so: [RoutePrefix("api/tms/auth")] public class AuthController : BaseController { public ISecurityService SecurityService { get; set; } [TokenAuth] [Route("logout")] [HttpPost] public HttpResponseMessage Logout() { try

Swagger query parameter template

痴心易碎 提交于 2019-12-11 15:52:40
问题 I have on query parameter which is little bit complex and i have my own syntax to make that value. Its has more then one variable to make one complete string value. Let suppose name of parameter is index which has row and column like to make this value 20:30 index = { row: 20, col:30 } index2 = { row: 20, col:30, chr: 15 } Now i wanted to make it as example.com?index=20:30 example.com?index2=20:30:15 Can someone tell me how can i define this in swagger ? Thank you. 回答1: Make your swagger

Set List of Objects in Swagger API response

别等时光非礼了梦想. 提交于 2019-12-11 15:37:38
问题 I want to send a list of objects in the response of an API using Swagger. @ApiResponse(code = 200, message = ApiResponseMessages.ITEM_FETCHED, response = "") I have a class - class Item{ int id; String item_name; } I want a response like - { { "id" : 0, "item_name" : "" } { "id" : 0, "item_name" : "" } { "id" : 0, "item_name" : "" } } How can i do this. Any help would be appreciated. 回答1: You also can set a ApiReponse like this: @ApiResponse(code = 200, message = ApiResponseMessages.ITEM