Ejemplo n.º 1
0
 private Operation CreatePostOperation(SwaggerPathsResource swaggerResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             SwaggerDocumentHelper.GetResourcePluralName(swaggerResource.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" + swaggerResource.Name,
         deprecated = swaggerResource.IsDeprecated,
         consumes = new[] { _contentTypeStrategy.GetOperationContentType(swaggerResource, ContentTypeUsage.Writable) },
         parameters = CreatePostParameters(swaggerResource),
         responses = SwaggerDocumentHelper.GetWriteOperationResponses(HttpMethod.Post)
     });
 }
Ejemplo n.º 2
0
 private Operation CreatePutByIdOperation(SwaggerPathsResource swaggerResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             SwaggerDocumentHelper.GetResourcePluralName(swaggerResource.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{swaggerResource.Name}",
         deprecated = swaggerResource.IsDeprecated,
         consumes = new[] { _contentTypeStrategy.GetOperationContentType(swaggerResource, ContentTypeUsage.Writable) },
         parameters = CreatePutParameters(swaggerResource),
         responses = SwaggerDocumentHelper.GetWriteOperationResponses(HttpMethod.Put)
     });
 }
Ejemplo n.º 3
0
 private Operation CreateDeleteByIdOperation(SwaggerPathsResource swaggerResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             SwaggerDocumentHelper.GetResourcePluralName(swaggerResource.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{swaggerResource.Name}ById",
         deprecated = swaggerResource.IsDeprecated,
         consumes = new[] { _contentTypeStrategy.GetOperationContentType(swaggerResource, ContentTypeUsage.Writable) },
         parameters = new[]
         {
             SwaggerDocumentHelper.CreateIdParameter(),
             CreateIfMatchParameter("DELETE from removing")
         },
         responses = SwaggerDocumentHelper.GetWriteOperationResponses(HttpMethod.Delete)
     });
 }