How to include XML comments files in Swagger in ASP.NET Core

For .Net Core 2 up to 8* versions it’s slightly different, for those who come across it using a newer version you would create your private void ConfigureSwagger(IServiceCollection services) constructor, add the reference to swagger services.AddSwaggerGen(c => { c.SwaggerDoc(/*populate with your info */); then define a new parameter which will be the path for your … Read more

Swagger: Add description with ref

For anyone using Swashbuckle with ASP.NET, you can use the following code to have the $ref construct put under the allOf (just like the : // do this wherever you are calling AddSwaggerGen() ArgBuilder.Services.AddSwaggerGen(opts => { opts.UseAllOfToExtendReferenceSchemas(); // add this line. }); Now if you have a model with two properties of the same type, … Read more

How can I describe complex json model in swagger

Okay, so based on the comments above, you want the following schema: { “definitions”: { “user”: { “type”: “object”, “required”: [ “name” ], “properties”: { “name”: { “type”: “string” }, “address”: { “type”: “array”, “items”: { “$ref”: “#/definitions/address” } } } }, “address”: { “type”: “object”, “properties”: { “type”: { “type”: “string”, “enum”: [ “home”, … Read more

Multipart File upload using Springfox and Swagger-ui

I think you are missing the consumes attribute of the @RequestMapping in your second snippet. See the following example @RequestMapping( path = “/upload”, method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity<String> handleUpload( @RequestPart(“file”) MultipartFile file, @RequestParam(“someId”) Long someId, @RequestParam(“someOtherId”) Long someOtherId) { return new ResponseEntity<>(); }

Grouping of API methods in documentation – is there some custom attribute

You could also use SwaggerOperationAttribute: public class UserController : ApiController { [Route(“api/user”)] [SwaggerOperation(Tags = new[] { “User” })] IHttpActionResult GetUser() { … } } public class ResumeController : ApiController { [Route(“api/user/resumes”)] [SwaggerOperation(Tags = new[] { “User” })] IHttpActionResult GetResumes() { … } }

Swagger UI passing authentication token to API call in header

@ApiImplicitParams and @ApiImplicitParam should do the trick: @GET @Produces(“application/json”) @ApiImplicitParams({ @ApiImplicitParam(name = “Authorization”, value = “Authorization token”, required = true, dataType = “string”, paramType = “header”) }) public String getUser(@PathParam(“username”) String userName) { … } From the documentation: You may wish you describe operation parameters manually. This can be for various reasons, for example: Using … Read more

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