How to make Swagger show examples of objects returned from the API?

That should be pretty straightforward: [Route(“{organizationSys:int}”)] [ProducesResponseType(typeof(List<Door>), 200)] [ProducesResponseType(typeof(string), 400)] public IHttpActionResult Get(int organizationSys) Note that since you have 2 exit points: one normal return with data, and a catch that returns error message, I’ve defined in the example above two possible result types: http:200(OK) with List<Door> http:400(BadRequest) with string Swashbuckle Swagger infrastructure will read … Read more

How do you create a swagger schema that includes an array of varying types

OpenAPI 3.0 supports oneOf and anyOf: schema: type: array items: oneOf: – $ref: ‘#/components/schemas/directiveRequire’ – $ref: ‘#/components/schemas/directiveReplace’ – … In OpenAPI 2.0, you can define an object with varying properties as just type: object (free-form object). For your case, you may want to do this: schema: type: array items: type: object

How to define global parameters in OpenAPI?

It depends on what kind of parameters they are. The examples below are in YAML (for readability), but you can use http://www.json2yaml.com to convert them to JSON. Security-related parameters: Authorization header, API keys, etc. Parameters used for authentication and authorization, such as the Authorization header, API key, pair of API keys, etc. should be defined … Read more

Why is v2/api-docs the default URL when using springfox and Swagger2?

The /v2/api-docs URL is the default that SpringFox uses for documentation. The v2 does not refer to your API’s documentation version (which can be changed in the Docket configuration), but the version of the Swagger specification being used. Take a look at the documentation here for customizing the Swagger documentation URL. In short, you need … Read more

How to set up Swashbuckle vs Microsoft.AspNetCore.Mvc.Versioning

At the moment Swashbuckle and Microsoft.AspNetCore.Mvc.Versioning are friends. It works good. I just created test project in VS2017 and checked how it works. First include these two nuget packages: <PackageReference Include=”Microsoft.AspNetCore.Mvc.Versioning” Version=”1.2.1″ /> <PackageReference Include=”Swashbuckle.AspNetCore” Version=”1.0.0″ /> Configure everything in Startup.cs (read my comments): public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Configure versions services.AddApiVersioning(o => … Read more

Not supported by Swagger 2.0: Multiple operations with path

In the file AppStart/SwaggerConfig.cs First one, you must import Linq using System.Linq; And add in the same file, this line c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); just inside of: GlobalConfiguration.Configuration .EnableSwagger(c => { … One consideration: In your controllers, you must use the Http methods : [HttpGet] [Route(“something”)] public List<model> something(){….} [HttpGet] [Route(“something2”)] public List<model2> something2(){….} [HttpPost] [Route(“mypost1”)] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)