private OpenApiPathItem Add(string method, string permission, string path, Action <OpenApiOperation> updater) { var operations = document.Paths.GetOrAddNew($"{appPath}/{schemaPath}{path}"); var operation = new OpenApiOperation { Security = new List <OpenApiSecurityRequirement> { new OpenApiSecurityRequirement { [Constants.SecurityDefinition] = new[] { Permissions.ForApp(permission, appName, schemaPath).Id } } } }; updater(operation); operations[method] = operation; if (path.StartsWith("/{id}", StringComparison.OrdinalIgnoreCase)) { operation.AddPathParameter("id", JsonObjectType.String, $"The id of the {schemaName} content."); operation.AddResponse("404", $"App, schema or {schemaName} content not found."); } return(operations); }
private OpenApiPathItem AddOperation(string method, string entityName, string path, Action <OpenApiOperation> updater) { var operations = document.Paths.GetOrAddNew(path); var operation = new OpenApiOperation(); updater(operation); operations[method] = operation; if (entityName != null) { operation.AddPathParameter("id", JsonObjectType.String, $"The id of the {entityName} content (GUID)."); operation.AddResponse("404", $"App, schema or {entityName} content not found."); } return(operations); }