0
votes

I want to create Swagger.json based on my own custom information, so I tested SwaggerDocument and OpenApiDocument, but got no answer.

Please help me - how to create my own custom file with SwaggerDocument or OpenApiDocument Swagger.json, or by using any other package I can do this.

public static SwaggerDocument CreateSwaggerDocument()
{
            try
            {
                SwaggerDocument swaggerDocument = new SwaggerDocument();
                swaggerDocument.info = new Info
                {
                    title = "Create-Test",
                    description = "This is a test",
                    version = "1.0"
                };

                var responses = new Dictionary<string, Response>();

                var response = new Response
                {
                    description = "res",
                    schema = new Schema
                    {
                        @ref = "#/definitions/customer"
                    }
                };

                responses.Add("customer", response);

                var lst = new List<Parameter>();
                lst.Add(new Parameter { @in = "input", description = "assassa", @ref = "#/definitions/customer" });

                var operation = new Operation
                {
                    tags = null,
                    operationId ="sdsadas",
                    produces = null,
                    consumes = null,
                    parameters =  null,
                    responses = responses,
                    deprecated = false
                };

                var path = new Dictionary<string, PathItem>();
                path.Add("test", new PathItem
                {
                    get = operation
                });

                swaggerDocument.paths = path;

                return swaggerDocument;
            }
            catch (Exception ex)
            {
                throw;
            }
}
thank you, I read this, but what I want to do is get the information I want through the document and create swagger.jsonali