swagger-2.0

How to keep the single resource representation approach using OpenAPI spec

家住魔仙堡 提交于 2019-12-04 06:11:44
问题 Reading this post (see: 3 How to use a single definition when... ) about describing a REST API using OpenAPI (Swagger) specification you can note how to keep a single resource representation for adding/updating and getting resource using readOnly property instead of having one representation for getting (GET a collection item) and other one for adding (POST to a collection). For example, in the following User single representation, the id is a read-only property which mean that it won't be

Swagger- Schemes HTTP and HTTPS with different ports

你说的曾经没有我的故事 提交于 2019-12-04 05:09:11
问题 How does one specify multiple schema with different ports? Specifically, I want to have HTTP on port 81 and HTTPS on port 444. swagger: '2.0' info: version: 1.0.0 title: API for gateways description: API for gateways to access server (port 81 for http and 444 for https) schemes: - http - https host: gateway.example.com:81 basePath: /1.0 paths: 回答1: This is possible in OpenAPI 3.0, but not in OpenAPI/Swagger 2.0. openapi: 3.0.0 servers: - url: 'http://gateway.example.com:81' - url: 'https:/

.NET Core 2 and SwashBuckle Swagger UI is not Displaying

谁说我不能喝 提交于 2019-12-04 03:36:16
I have followed a few tutorials and have gotten this to work at work but for some reason I am not able to get the UI to display but the Swagger Json is created. Last tutorial I looked at is here . My setup is like so: Nuget Package: Swashbuckle.AspNetCore(1.0.0) ConfigureServices Method: services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "MediatR Example", Version = "v1", Description = "Trying out the MediatR library to simplify Request and Response logic.", TermsOfService = "WTFPL", Contact = new Contact { Email = "", Name = "", Url = "https://github.com

Unable to infer base url… springfox-swagger2 version 2.9.2

南楼画角 提交于 2019-12-04 02:00:13
问题 Version of springfox-swagger that I am using What kind of issue is this? Project structure: SwaggerConfig is in automate.api.config.swagger.SwaggerConfiguration Auth Config is in automate.api.web.auth.keycloak.FalconKeycloakConfigurerAdapter dependencies As for Spring Boot <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> </parent> As for swagger <dependency> <groupId>io.springfox</groupId>

Define array of multiple models in Swagger 2.0

吃可爱长大的小学妹 提交于 2019-12-04 01:50:22
This is my first foray into Swagger so please be gentle. I have the following definitions: definitions: Payload: type: object properties: indicators: type: array items: $ref: '#/definitions/Indicator' Indicator: type: object properties: type: type: string computeOn: type: array items: type: string default: - close parameters: type: object BBANDS: properties: type: type: string default: BBANDS computeOn: type: array items: type: string default: - close parameters: type: object properties: timeperiod: type: integer format: int32 default: 5 nbdevup: type: integer format: int32 default: 2 nbdevdn:

Write swagger doc that consumes multiple content types e.g. application/json AND application/x-www-form-urlencoded (w/o duplication)

╄→гoц情女王★ 提交于 2019-12-03 16:33:22
I'm looking for an elegant way to define an api that can consume JSON data as well as form data. The following snippet works, but it's not elegant and requires all kind of ugly code in the backend. Is there a better way to define this? What works right now: paths: /pets: post: consumes: - application/x-www-form-urlencoded - application/json parameters: - name: nameFormData in: formData description: Updated name of the pet required: false type: string - name: nameJSON in: body description: Updated name of the pet required: false type: string Basic idea of how I'd like it to work: paths: /pets:

Subpaths in Swagger YAML declaration

若如初见. 提交于 2019-12-03 16:28:11
I am trying to create a REST service by describing it in Swagger YAML. The service has three paths: /versions /partners/{partnerId}/users/{userId}/sessions /partners/{partnerId}/books/{bookId}/ My current YAML file to describe these paths looks like this: swagger: '2.0' info: version: '0.0.1' title: Test API host: api.test.com basePath: / schemes: - https consumes: - application/json produces: - application/json paths: /versions: post: responses: '201': description: Returns all versions. default: description: unexpected error /partners/{partnerId}/users/{userId}/sessions: parameters: - name:

How can I tell Swashbuckle that the body content is required?

六月ゝ 毕业季﹏ 提交于 2019-12-03 13:25:46
I have a WebAPI controller that accepts binary packages and stores them somewhere. As these packages can become quite large, I don't want to load them into memory by adding a byte array parameter but rather pass along a stream. I found a way to do that in this answer : [HttpPost] [Route("Store/{projectId}")] public async Task Store(string projectId) { using (var stream = await this.Request.Content.ReadAsStreamAsync()) { await this.packageManager.StorePackageAsync(projectId, stream); } } This works, I can send files to the controller using Postman. However, I now want to generate swagger

Spring Boot & Swagger UI. Set JWT token

一曲冷凌霜 提交于 2019-12-03 07:30:04
问题 I have a Swagger config like this @EnableSwagger2 @Configuration public class SwaggerConfig { @Bean public Docket api() { List<SecurityScheme> schemeList = new ArrayList<>(); schemeList.add(new ApiKey(HttpHeaders.AUTHORIZATION, "JWT", "header")); return new Docket(DocumentationType.SWAGGER_2) .produces(Collections.singleton("application/json")) .consumes(Collections.singleton("application/json")) .ignoredParameterTypes(Authentication.class) .securitySchemes(schemeList)

Django REST Framework Swagger 2.0

南笙酒味 提交于 2019-12-03 05:02:53
问题 Having a hard time configuring Swagger UI Here are the very explanatory docs: https://django-rest-swagger.readthedocs.io/en/latest/ YAML docstrings are deprecated. Does somebody know how to configure Swagger UI from within the python code? or what file should I change to group api endpoints, to add comments to each endpoint, to add query parameter fields in Swagger UI? 回答1: This is how I managed to do it: base urls.py urlpatterns = [ ... url(r'^api/', include('api.urls', namespace='api')),