Skip to content

Add more metadata #824

Closed
Closed
@JKamsker

Description

@JKamsker

For minimal apis, i miss methods to add descriptions

app
        .DefineApi("People")
        .HasMapping(api =>
        {
            api.MapGet("/api/v{version:apiVersion}/people/{id:int}", (int id) => "Some response")
              .Produces(response => response.Body<WeatherForecast>())
              .Produces(404)
              .HasApiVersion(1.0)
              ;

        });

Produces:

{
    "x-generator": "NSwag v13.15.10.0 (NJsonSchema v10.6.10.0 (Newtonsoft.Json v9.0.0.0))",
    "openapi": "3.0.0",
    "info": {
        "title": "Minimal API",
        "version": "1"
    },
    "servers": [
        {
            "url": "https://localhost:7174"
        }
    ],
    "paths": {
        "/api/v1/people/{id}": {
            "get": {
                "tags": [
                    "people"
                ],
                "operationId": "GetApiV1People",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int32"
                        },
                        "x-position": 1
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WeatherForecast"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "WeatherForecast": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "date": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "temperatureC": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "temperatureF": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "summary": {
                        "type": "string",
                        "nullable": true
                    }
                }
            }
        }
    }
}

In this example i want to be able to add paths.['/api/v1/people/{id}'].get.description and paths.['/api/v1/people/{id}'].get.responses.['200'].description which is currently (6.0.0-preview.2) not possible

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions