private static void GenerateSchemaOperations(OperationsBuilder builder) { builder.AddOperation(OpenApiOperationMethod.Get, "/") .RequirePermission(Permissions.AppContentsReadOwn) .Operation("Query") .OperationSummary("Query schema contents items.") .Describe(Properties.Resources.OpenApiSchemaQuery) .HasQueryOptions(true) .Responds(200, "Content items retrieved.", builder.ContentsSchema) .Responds(400, "Query not valid."); builder.AddOperation(OpenApiOperationMethod.Get, "/{id}") .RequirePermission(Permissions.AppContentsReadOwn) .Operation("Get") .OperationSummary("Get a schema content item.") .HasId() .Responds(200, "Content item returned.", builder.ContentSchema); builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/{version}") .RequirePermission(Permissions.AppContentsReadOwn) .Operation("Get") .OperationSummary("Get a schema content item by id and version.") .HasPath("version", JsonObjectType.Number, "The version of the content item.") .HasId() .Responds(200, "Content item returned.", builder.ContentSchema); builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/validity") .RequirePermission(Permissions.AppContentsReadOwn) .Operation("Validate") .OperationSummary("Validates a schema content item.") .HasId() .Responds(200, "Content item is valid.") .Responds(400, "Content item is not valid."); builder.AddOperation(OpenApiOperationMethod.Post, "/") .RequirePermission(Permissions.AppContentsCreate) .Operation("Create") .OperationSummary("Create a schema content item.") .HasQuery("publish", JsonObjectType.Boolean, "True to automatically publish the content.") .HasQuery("id", JsonObjectType.String, "The optional custom content id.") .HasBody("data", builder.DataSchema, Properties.Resources.OpenApiSchemaBody) .Responds(201, "Content item created", builder.ContentSchema) .Responds(400, "Content data not valid."); builder.AddOperation(OpenApiOperationMethod.Post, "/{id}") .RequirePermission(Permissions.AppContentsUpsert) .Operation("Upsert") .OperationSummary("Upsert a schema content item.") .HasQuery("publish", JsonObjectType.Boolean, "True to automatically publish the content.") .HasId() .HasBody("data", builder.DataSchema, Properties.Resources.OpenApiSchemaBody) .Responds(200, "Content item created or updated.", builder.ContentSchema) .Responds(400, "Content data not valid."); builder.AddOperation(OpenApiOperationMethod.Put, "/{id}") .RequirePermission(Permissions.AppContentsUpdateOwn) .Operation("Update") .OperationSummary("Update a schema content item.") .HasId() .HasBody("data", builder.DataSchema, Properties.Resources.OpenApiSchemaBody) .Responds(200, "Content item updated.", builder.ContentSchema) .Responds(400, "Content data not valid."); builder.AddOperation(OpenApiOperationMethod.Patch, "/{id}") .RequirePermission(Permissions.AppContentsUpdateOwn) .Operation("Patch") .OperationSummary("Patch a schema content item.") .HasId() .HasBody("data", builder.DataSchema, Properties.Resources.OpenApiSchemaBody) .Responds(200, "Content item updated.", builder.ContentSchema) .Responds(400, "Content data not valid."); builder.AddOperation(OpenApiOperationMethod.Put, "/{id}/status") .RequirePermission(Permissions.AppContentsUpdateOwn) .Operation("Patch") .OperationSummary("Patch a schema content item.") .HasId() .HasBody("data", builder.DataSchema, Properties.Resources.OpenApiSchemaBody) .Responds(200, "Content item updated.", builder.ContentSchema) .Responds(400, "Content data not valid."); builder.AddOperation(OpenApiOperationMethod.Delete, "/{id}") .RequirePermission(Permissions.AppContentsChangeStatusOwn) .Operation("Change") .OperationSummary("Change the status of a schema content item.") .HasId() .HasBody("request", builder.Parent.ChangeStatusSchema, "The request to change content status.") .Responds(200, "Content status updated.", builder.ContentSchema); builder.AddOperation(OpenApiOperationMethod.Delete, "/{id}") .RequirePermission(Permissions.AppContentsDeleteOwn) .Operation("Delete") .OperationSummary("Delete a schema content item.") .HasId() .Responds(204, "Content item deleted"); }
public OperationBuilder(OperationsBuilder operations, OpenApiOperation operation) { this.operations = operations; this.operation = operation; }