public OperationsBuilder Shared() { var dataSchema = RegisterReference("DataDto", _ => { return(JsonSchema.CreateAnySchema()); }); var contentSchema = RegisterReference("ContentDto", _ => { return(ContentJsonSchemaBuilder.BuildSchema(dataSchema, true)); }); var contentsSchema = RegisterReference("ContentResultDto", _ => { return(BuildResult(contentSchema)); }); var path = $"/content/{AppName}"; var builder = new OperationsBuilder { ContentSchema = contentSchema, ContentsSchema = contentsSchema, DataSchema = dataSchema, Path = path, Parent = this, SchemaDisplayName = "__Shared", SchemaName = "__Shared", SchemaTypeName = "__Shared" }; builder.AddTag("API endpoints for operations across all schemas."); return(builder); }
public OperationsBuilder Schema(Schema schema, PartitionResolver partitionResolver, ResolvedComponents components, bool flat) { var typeName = schema.TypeName(); var dataSchema = RegisterReference($"{typeName}DataDto", _ => { return(schema.BuildJsonSchemaDynamic(partitionResolver, components, CreateReference, false, true)); }); var contentDataSchema = dataSchema; if (flat) { contentDataSchema = RegisterReference($"{typeName}FlatDataDto", _ => { return(schema.BuildJsonSchemaFlat(partitionResolver, components, CreateReference, false, true)); }); } var contentSchema = RegisterReference($"{typeName}ContentDto", _ => { return(ContentJsonSchema.Build(contentDataSchema, true)); }); var contentsSchema = RegisterReference($"{typeName}ContentResultDto", _ => { return(BuildResult(contentSchema)); }); var path = $"api/content/{AppName}/{schema.Name}"; var builder = new OperationsBuilder { ContentSchema = contentSchema, ContentsSchema = contentsSchema, DataSchema = dataSchema, Path = path, Parent = this, SchemaDisplayName = schema.DisplayName(), SchemaName = schema.Name, SchemaTypeName = typeName }; builder.AddTag("API endpoints for [schema] content items."); return(builder); }