protected override void DrawQueryParameters(List <Parameter> docEntryQueryParameter)
        {
            if (!docEntryQueryParameter.Any())
            {
                return;
            }

            _document.P();
            _document.H2().SetText("Query string parameters");
            var table = _document.Table();

            table.AddColumns(new TextContent("Name"), new TextContent("Type"), new TextContent("Schema"), new TextContent("Description"));
            foreach (var parameter in docEntryQueryParameter)
            {
                var         nameCell   = new TextContent(parameter.Name ?? "");
                var         typeCell   = new TextContent(parameter.Type ?? "");
                HtmlElement schemaCell = new TextContent("");
                if (parameter.Schema != null)
                {
                    var schema = PdfModelJsonConverter.SerializeObject(parameter.Schema);
                    schemaCell = HtmlElement.Pre().SetText(schema);
                }

                var descriptionCell = HtmlElement.P();
                WriteDetailedDescription(descriptionCell, parameter);
                table.AddRow(nameCell, typeCell, schemaCell, descriptionCell);
            }
        }
        protected override void DrawBodyParameters(List <Parameter> docEntryBodyParameters)
        {
            if (!docEntryBodyParameters.Any())
            {
                return;
            }

            _document.P();
            _document.H2().SetText("Request body parameters");

            foreach (var bodyParameter in docEntryBodyParameters)
            {
                var schema = PdfModelJsonConverter.SerializeObject(bodyParameter.Schema);
                _document.Pre().SetText(schema);
            }
        }
Example #3
0
        public override void WriteDetailedDescription(IAuthorizationWriter writer)
        {
            if (CollectionFormat == "multi")
            {
                writer.AppendText("Multiple values allowed");
                writer.AddLineBreak();
            }

            if (DefaultValue != null)
            {
                writer.AppendText("Default value: ");
                writer.AddFixedSizeCharElement(PdfModelJsonConverter.SerializeObject(DefaultValue));
                writer.AddLineBreak();
            }

            writer.AppendText("Allowed values:");
            writer.AddFixedSizeCharElement(PdfModelJsonConverter.SerializeObject(EnumValues));
        }
        protected override void DrawResponses(List <Response> docEntryResponses)
        {
            if (!docEntryResponses.Any())
            {
                return;
            }

            _document.P();
            _document.H2().SetText("Responses");

            foreach (var response in docEntryResponses)
            {
                var p = _document.P().SetText($"{response.Code}: {response.Description}")
                        .SetStyle("border", "1px solid #c6cbd1");

                if (response.Schema != null)
                {
                    var responseBody = PdfModelJsonConverter.SerializeObject(response.Schema);
                    p.AddChildElement(HtmlElement.Pre().SetText(responseBody));
                }
            }
        }