How to describe a model in Swagger for an array with simple objects?

Tony YUEN was close, but no cigar. This is the proper definition using YAML in OpenAPI/Swagger: /test: post: summary: test 123 description: test 123 parameters: – name: param1 in: body required: true description: test param1 schema: $ref: ‘#/definitions/stackoverflow’ responses: 200: description: OK This produces: stackoverflow2[ { name: string } ] Tony’s example produces: [ stackoverflow … Read more

How to post files in Swagger (OpenAPI)?

OpenAPI Specification 2.0 In Swagger 2.0 (OpenAPI Specification 2.0), use a form parameter (in: formData) with the type set to file. Additionally, the operation’s consumes must be multipart/form-data. consumes: – multipart/form-data parameters: – name: file in: formData # <—– description: The uploaded file data required: true type: file # <—– OpenAPI Specification 3.0 In OpenAPI … Read more

How to define an enum in OpenAPI (Swagger)?

“enum” works like this in OpenAPI 2.0: { “in”: “query”, “name”: “sample”, “description”: “a sample parameter with an enum value”, “type”: “string”, “enum”: [ “1”, “2”], “required”: true } and in OpenAPI 3.0: { “in”: “query”, “name”: “sample”, “description”: “a sample parameter with an enum value”, “schema”: { “type”: “string”, “enum”: [ “1”, “2”] }, … Read more

Api annotation’s description is deprecated

I found two solutions for Spring Boot application: 1. Swagger 2 based: Firstly, use the tags method for specify the tags definitions in your Docket bean: @Configuration @EnableSwagger2 public class Swagger2Config { public static final String TAG_1 = “tag1”; @Bean public Docket productApi() { return new Docket(DocumentationType.SWAGGER_2).select() .apis(RequestHandlerSelectors.basePackage(“my.package”)).build() .tags(new Tag(TAG_1, “Tag 1 description.”)) // Other … Read more

How to format Swagger 2.0 text descriptions?

Markdown is supported in the Swagger Editor. Below is an example of using Markdown in an OpenAPI (Swagger) document: swagger: ‘2.0’ info: version: 0.0.0 title: Markdown description: | # Heading Text attributes _italic_, *italic*, __bold__, **bold**, `monospace`. Horizontal rule: — Bullet list: * apples * oranges * pears Numbered list: 1. apples 2. oranges 3. … Read more

Generate static docs with swagger

Use swagger-codegen: swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location> If you decide to customize the HTML template: Clone the swagger-codegen project from github Copy modules/swagger-codegen/src/main/resources/htmlDocs2 folder to another place, for example: cp -R modules/swagger-codegen/src/main/resources/htmlDocs2 ~/templates Modify the .mustache templates in ~/templates to fit your requirements. Run: swagger-codegen … Read more

How to configure Swashbuckle to ignore property on model

If you need to do this but without using JsonIgnore (maybe you still need to serialize/deserialize the property) then just create a custom attribute. [AttributeUsage(AttributeTargets.Property)] public class SwaggerExcludeAttribute : Attribute { } Then a schema filter similar to Johng’s public class SwaggerExcludeFilter : ISchemaFilter { #region ISchemaFilter Members public void Apply(Schema schema, SchemaRegistry schemaRegistry, Type … Read more

A ‘simple’ way to implement Swagger in a Spring MVC application

Springfox (Swagger spec 2.0, current) Springfox has replaced Swagger-SpringMVC, and now supports both Swagger specs 1.2 and 2.0. The implementation classes have changed, allowing for some deeper customization, but with some work. The documentation has improved, but still needs some details added for advanced configuration. The old answer for the 1.2 implementation can still be … Read more

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