private Operation CreateDeleteByIdOperation(OpenApiMetadataPathsResource openApiMetadataResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
             .ToCamelCase()
         },
         summary = "Deletes an existing resource using the resource identifier.",
         description =
             "The DELETE operation is used to delete an existing resource by identifier. If the resource doesn't exist, an error will result (the resource will not be found).",
         operationId = $"delete{openApiMetadataResource.Name}ById",
         deprecated = openApiMetadataResource.IsDeprecated,
         consumes = new[]
         {
             _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
         },
         parameters = new[]
         {
             OpenApiMetadataDocumentHelper.CreateIdParameter(),
             CreateIfMatchParameter("DELETE from removing")
         },
         responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Delete)
     });
 }
Exemple #2
0
        private Operation CreatePostOperation(OpenApiMetadataPathsResource openApiMetadataResource)
        {
            var responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Post);

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                responses.Add(
                    "405",
                    new Response
                {
                    description =
                        "Method Is Not Allowed. When the Snapshot-Identifier header is present the method is not allowed."
                });
            }

            return(new Operation
            {
                tags = new List <string>
                {
                    OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
                    .ToCamelCase()
                },
                summary = "Creates or updates resources based on the natural key values of the supplied resource.",
                description =
                    "The POST operation can be used to create or update resources. In database terms, this is often referred to as an \"upsert\" operation (insert + update). Clients should NOT include the resource \"id\" in the JSON body because it will result in an error. The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately. It is recommended to use POST for both create and update except while updating natural key of a resource in which case PUT operation must be used.",
                operationId = "post" + openApiMetadataResource.Name,
                deprecated = openApiMetadataResource.IsDeprecated,
                consumes = new[]
                {
                    _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
                },
                parameters = CreatePostParameters(openApiMetadataResource),
                responses = responses
            });
        }
Exemple #3
0
        private Operation CreatePutByIdOperation(OpenApiMetadataPathsResource openApiMetadataResource)
        {
            var responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Put);

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                responses.Add(
                    "405",
                    new Response
                {
                    description =
                        "Method Is Not Allowed. When the Snapshot-Identifier header is present the method is not allowed."
                });
            }

            return(new Operation
            {
                tags = new List <string>
                {
                    OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
                    .ToCamelCase()
                },
                summary = "Updates a resource based on the resource identifier.",
                description = GetDescription(openApiMetadataResource),
                operationId = $"put{openApiMetadataResource.Name}",
                deprecated = openApiMetadataResource.IsDeprecated,
                consumes = new[]
                {
                    _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
                },
                parameters = CreatePutParameters(openApiMetadataResource),
                responses = responses,
                isUpdatable = GetIsUpdatableCustomMetadataValue(openApiMetadataResource)
            });
        }
 private Operation CreatePostOperation(OpenApiMetadataPathsResource openApiMetadataResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
             .ToCamelCase()
         },
         summary = "Creates or updates resources based on the natural key values of the supplied resource.",
         description =
             "The POST operation can be used to create or update resources. In database terms, this is often referred to as an \"upsert\" operation (insert + update). Clients should NOT include the resource \"id\" in the JSON body because it will result in an error (you must use a PUT operation to update a resource by \"id\"). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately.",
         operationId = "post" + openApiMetadataResource.Name,
         deprecated = openApiMetadataResource.IsDeprecated,
         consumes = new[]
         {
             _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
         },
         parameters = CreatePostParameters(openApiMetadataResource),
         responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Post)
     });
 }
 private Operation CreatePutByIdOperation(OpenApiMetadataPathsResource openApiMetadataResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
             .ToCamelCase()
         },
         summary = "Updates or creates a resource based on the resource identifier.",
         description =
             "The PUT operation is used to update or create a resource by identifier. If the resource doesn't exist, the resource will be created using that identifier. Additionally, natural key values cannot be changed using this operation, and will not be modified in the database.  If the resource \"id\" is provided in the JSON body, it will be ignored as well.",
         operationId = $"put{openApiMetadataResource.Name}",
         deprecated = openApiMetadataResource.IsDeprecated,
         consumes = new[]
         {
             _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
         },
         parameters = CreatePutParameters(openApiMetadataResource),
         responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Put)
     });
 }
Exemple #6
0
        private Operation CreateDeleteByIdOperation(OpenApiMetadataPathsResource openApiMetadataResource)
        {
            var responses = OpenApiMetadataDocumentHelper.GetWriteOperationResponses(HttpMethod.Delete);

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                responses.Add(
                    "405",
                    new Response
                {
                    description =
                        "Method Is Not Allowed. When the Snapshot-Identifier header is present the method is not allowed."
                });
            }

            return(new Operation
            {
                tags = new List <string>
                {
                    OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
                    .ToCamelCase()
                },
                summary = "Deletes an existing resource using the resource identifier.",
                description =
                    "The DELETE operation is used to delete an existing resource by identifier. If the resource doesn't exist, an error will result (the resource will not be found).",
                operationId = $"delete{openApiMetadataResource.Name}ById",
                deprecated = openApiMetadataResource.IsDeprecated,
                consumes = new[]
                {
                    _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Writable)
                },
                parameters = new[]
                {
                    OpenApiMetadataDocumentHelper.CreateIdParameter(),
                    CreateIfMatchParameter("DELETE from removing")
                },
                responses = responses
            });
        }