swagger

SwaggerUI not displaying Model Schema

喜欢而已 提交于 2019-12-22 18:01:42
问题 I have a C# Web.API project with Swagger and Swashbuckle. I have a model: public class TimeZoneName { public string zoneName { get; } } I have a controller with methods: public string GetLocalTimeByTimeZone(TimeZoneName timezone) { //Stuff Happens here return "12:00"; } During a build I was expecting Swashbuckle to generate a SwaggerUI that shows a JSON representation of the TimeZoneName type in the UI. That didn't occur. How do I set up my methods and models so that the Model Schema is shown

Swashbuckle rename Data Type in Model

佐手、 提交于 2019-12-22 11:12:48
问题 I'm putting together a web API that needs to match an external sources XML format and was looking to rename the Data Type objects in the swagger output. It's working fine on the members of the class but I was wondering if it was possible to override the class name as well. Example: [DataContract(Name="OVERRIDECLASSNAME")] public class TestItem { [DataMember(Name="OVERRIDETHIS")] public string toOverride {get; set;} } In the generated output I end up seeing Model: TestItem { OVERRIDETHIS

Route Disambiguation in ASP.NET Core (MVC 6)

隐身守侯 提交于 2019-12-22 09:49:52
问题 When ASP.NET Core encounters ambiguously named routes, it becomes inert. That is, the application will run without exceptions thrown but, it will fail to process any requests, on any controllers. The calling client receives 500 responses. I'll show how I got into this mess, and I'd like suggestions of how to fix it. I have a controller that looks like this: [Route("api/Subscribers/{id}/[controller]")] [Route("api/Organizations/{id}/[controller]")] public class AddressesController : Controller

How to call swagger codegen programmatically?

十年热恋 提交于 2019-12-22 09:37:55
问题 I am generating a restful java jax-rs api with swagger-codgen-cli.jar. Right now I call java -jar with some command line options to do this. java -jar swagger-codegen-cli.jar generate -i api.yaml -l jaxrs -o ./outputdir Which works fine. But I would like to make this call from of a Java program i.e. including the codegen.jar into my classpath and then call the corresponding method with similar parameters. So is there a public API from the swagger-codegen module which I can call? 回答1: If I

How do I parametrize a URL for POST using Swagger?

巧了我就是萌 提交于 2019-12-22 09:24:50
问题 I would like to define the following path using Swagger: /api/libraries/1234/books And POST a book to the books collection of library, whose id is 1234 . In the example, I've seen here: https://github.com/swagger-api/swagger-spec/blob/master/examples/v2.0/json/petstore-with-external-docs.json It shows like, you can specify for example: libraries/{id}/books , but you have to define it as a separate path object. For example, comparing with libraries , for GET purposes; which will retrieve you a

SpringFox dependency breaking my Spring Context

◇◆丶佛笑我妖孽 提交于 2019-12-22 09:14:29
问题 Until recently I've been getting my swagger documentation mostly-free, because I was using Camel to expose my REST APIs. I've had to ditch Camel because of some problems it has playing nice with Jackson, so I'm trying to set up SpringFox. Unfortunately, simply adding SpringFox as a dependency wrecks my Spring context somehow, and throws a vague and incorrect error claiming I don't have an explicit ObjectMapper bean, which I do - the inability to make Camel use said bean is why I had to remove

Upload a file in Swagger and receive at Flask backend

蓝咒 提交于 2019-12-22 08:44:50
问题 I'm trying to upload a file using Swagger and Flask. I've the following configuration for swagger. "/user/register/": { "post": { "tags": ["user"], "summary": "Register a new user", "description": "", "operationId": "registerUser", "consumes": ["application/json"], "produces": ["application/json"], "parameters": [{ "in": "body", "name": "body", "description": "User object that needs to be added.", "required": true, "schema": { "$ref": "#/definitions/User" } }, { "name": "file", "in": "path",

Swagger cross out method

旧街凉风 提交于 2019-12-22 08:24:33
问题 I am using Swaschbuckle for my .NET Swagger Web API Service. I have looked at the sample from http://petstore.swagger.io/#/pet and there ist the Action findByTags which is crossed out. I want to cross out an action in my api service, but when i am using the obsolete attribute the action isn't visible. Any idea how to handle this issue? 回答1: I had the same problem with my WebApi project, but after updating Swashbuckle.Core nuget package to version 5.6.0 it started to work. I have a

Swagger/OpenAPI multiple security requirements and side effects?

ぃ、小莉子 提交于 2019-12-22 07:59:18
问题 I am implementing a code generator for Swagger/OpenAPI. However, I run into a problem implementing the security requirement. These requirements are defined as a list of objects. The list members are alternatives (or) and the object members are anded. For example: [ { a:[], b:{} }, { c:{}, d:{} } ] This supposed to result in (a && b) || ( c && d) However, implementing this I run into the problem that the actual security requirements have side effects: OAuth2 - Must redirect if it fails Basic –

Swagger/Openapi-Annotations: How to produce allOf with $ref?

倖福魔咒の 提交于 2019-12-22 07:58:20
问题 I'm generating Rest endpoints including adding Openapi/Swagger annotations to the generated code. While it works quite well with basic types, I have some problems with custom classes. Right now I have a lot of duplicate schema entries for the custom classes (using @Schema(implementation = MyClass.class)) but at least the needed information is there. However I'd like to find a way to remove the duplicate schema entries while retaining the additional information . On a github-issue discussing