openapi

OpenApi/Swagger - What is the difference between Client and Server?

我与影子孤独终老i 提交于 2019-12-24 03:28:13
问题 I've built a RESTful service exposing an endpoint using OpenApi 3.0 using yaml When I build this, it auto-generates a client directory and a server directory. I am successfully leveraging the server API as an endpoint which consumes requests. However the client API is generated from exactly the same yaml ...accepting the same argument type and returning the same type as the server. My understanding was a client produces requests to an external service, while a server consumes requests from an

Go structs to OpenAPI to JSONSchema generation automatically

蹲街弑〆低调 提交于 2019-12-24 01:29:15
问题 I have a Go struct for which I want to generate an OpenAPI schema automatically. Once I have an OpenAPI definition of that struct I wanna generate JSONSchema of it, so that I can validate the input data that comes and is gonna be parsed into those structs. The struct looks like the following: // mySpec: io.myapp.MinimalPod type MinimalPod struct { Name string `json:"name"` // k8s: io.k8s.kubernetes.pkg.api.v1.PodSpec v1.PodSpec } Above struct is clearly an augmentation of what Kubernetes

Swagger 3.0 schema error “should NOT have additional properties”

一世执手 提交于 2019-12-23 01:35:22
问题 What does this error below mean? (Running in Swagger Editor) Schema error should NOT have additional properties additionalProperty: /buildinfo, /clearcache, /countries/{countryId}/cinemas/{theatreid}/screens/{screenid}/layout, /countries/{countryId}/cinemas/{theatreid}/screens Jump to line 0 Below is my yaml file. openapi: "3.0.1" info: title: Mobile backend version: 1.0.0 license: name: Apache 2.0 paths: /buildinfo: get: description: Returns the build information (Version and Time stamp).

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

How to define global parameters that will apply to all paths?

梦想与她 提交于 2019-12-22 03:52:39
问题 I want to make the account parameter to be applied to all paths, without any exceptions. Is there any way to do this with Swagger 2? I don't want apply the account parameter for every path. { "swagger": "2.0", "info": { "version": "1.0", "title": "Doc" }, "host": "localhost", "schemes": [ "http" ], "produces": [ "application/json" ], "parameters": { "account": { "in": "header", "name": "X-ACCOUNT", "description": "Account id", "type": "string", "required": true } }, "paths": { "/account": {

How to describe a multipart response using OpenAPI (Swagger)?

微笑、不失礼 提交于 2019-12-20 02:34:31
问题 I have a service that creates a multipart file containing: a data byte array that represents an image buffer a JSON that represents information about the image (coord, format, etc.) Is it possible to model this custom response in an OpenAPI (Swagger) definition, using YAML? 回答1: Multipart responses can be described using OpenAPI 3.0, but not OpenAPI 2.0 (fka Swagger 2.0). openapi: 3.0.0 ... paths: /something: get: responses: '200': description: OK content: multipart/mixed: # <-- Content-Type

cannot convert from 'Microsoft.OpenApi.Models.OpenApiInfo' to 'Swashbuckle.AspNetCore.Swagger.Info'

淺唱寂寞╮ 提交于 2019-12-19 17:45:52
问题 I'm getting this error when tryign to run swashbuckle. Any ideas? I have this in my ConfigureServices Class services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "testing", Version = "v1" }); }); And this in my Configure Class app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); 回答1: I ran into this same issue today. After looking at the Microsoft documentation, it appears that SwaggerDoc is looking for a string and an

OpenAPI 3.0 Generic Data types

本秂侑毒 提交于 2019-12-19 14:28:02
问题 How can I best describe a generic response type which includes the real data type in OpenAPI 3. Simplified example: ApiResponse: data: object error: string But the /users endpoint should give: ApiResponse<List<User>> So that basically is: ApiResponse: data: List<User> error: string It looks like this is not possible at the moment, but just want to make sure. I guess the best way to do this now is to make named responses for every call and use allOf to refer to ApiResponse and implemenent data

How not to copy-paste 3 generic error responses in almost all paths?

天大地大妈咪最大 提交于 2019-12-19 05:36:05
问题 I want almost all my paths to have the following 3 generic error responses. How do I describe that in Swagger without copypasting these lines everywhere? 401: description: The requester is unauthorized. schema: $ref: '#/definitions/Error' 500: description: "Something went wrong. It's server's fault." schema: $ref: '#/definitions/Error' 503: description: Server is unavailable. Maybe there is maintenance? schema: $ref: '#/definitions/Error' Example of how I use this in a request: paths: /roles: