Example #1
0
        public OperationBuilder OperationSummary(string summary)
        {
            if (!string.IsNullOrWhiteSpace(summary))
            {
                operation.Summary = operations.FormatText(summary);
            }

            return(this);
        }
Example #2
0
        public OperationsBuilder Schema(Schema schema, bool flat)
        {
            var typeName = schema.TypeName();

            var displayName = schema.DisplayName();

            var dataSchema = ResolveSchema($"{typeName}DataDto", () =>
            {
                return(schema.BuildDynamicJsonSchema(ResolveSchema));
            });

            var contentSchema = ResolveSchema($"{typeName}ContentDto", () =>
            {
                var contentDataSchema = dataSchema;

                if (flat)
                {
                    contentDataSchema = ResolveSchema($"{typeName}FlatDataDto", () =>
                    {
                        return(schema.BuildFlatJsonSchema(ResolveSchema));
                    });
                }

                return(ContentJsonSchemaBuilder.BuildSchema(displayName, contentDataSchema, true));
            });

            var contentsSchema = ResolveSchema($"{typeName}ContentResultDto", () =>
            {
                return(BuildResult(contentSchema));
            });

            var path = $"/content/{AppName}/{schema.Name}";

            var builder = new OperationsBuilder
            {
                ContentSchema     = contentSchema,
                ContentsSchema    = contentsSchema,
                DataSchema        = dataSchema,
                Path              = path,
                Parent            = this,
                SchemaDisplayName = displayName,
                SchemaName        = schema.Name,
                SchemaTypeName    = typeName
            };

            var description = builder.FormatText("API endpoints for schema content items.");

            Document.Tags.Add(new OpenApiTag {
                Name = displayName, Description = description
            });

            return(builder);
        }