private Operation CreateGetOperation(OpenApiMetadataPathsResource openApiMetadataResource, bool isCompositeContext)
        {
            var operation = new Operation
            {
                tags = new List <string>
                {
                    OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
                    .ToCamelCase()
                },
                summary     = "Retrieves specific resources using the resource's property values (using the \"Get\" pattern).",
                description =
                    "This GET operation provides access to resources using the \"Get\" search pattern.  The values of any properties of the resource that are specified will be used to return all matching results (if it exists).",
                operationId = openApiMetadataResource.OperationId ?? $"get{openApiMetadataResource.Resource.PluralName}",
                deprecated  = openApiMetadataResource.IsDeprecated,
                produces    = new[]
                {
                    _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Readable)
                },
                parameters = CreateGetByExampleParameters(openApiMetadataResource, isCompositeContext),
                responses  = OpenApiMetadataDocumentHelper.GetReadOperationResponses(
                    _pathsFactoryNamingStrategy.GetResourceName(openApiMetadataResource, ContentTypeUsage.Readable),
                    true)
            };

            return(operation);
        }
Esempio n. 2
0
        private Dictionary <string, Response> CreateReadResponses(OpenApiMetadataPathsResource openApiMetadataResource, bool isArray)
        {
            var responses = OpenApiMetadataDocumentHelper.GetReadOperationResponses(
                _pathsFactoryNamingStrategy.GetResourceName(openApiMetadataResource, ContentTypeUsage.Readable),
                isArray);

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                responses.Add(
                    "410",
                    new Response
                {
                    description =
                        "Gone. An attempt to connect to the database for the snapshot specified by the Snapshot-Identifier header was unsuccessful (indicating the snapshot may have been removed)."
                });
            }

            return(responses);
        }
 private Operation CreateDeletesOperation(OpenApiMetadataPathsResource openApiMetadataResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
             .ToCamelCase()
         },
         summary = "Retrieves deleted resources based on change version.",
         description = "The DELETES operation is used to retrieve deleted resources.",
         operationId = $"deletes{openApiMetadataResource.Resource.PluralName}",
         deprecated = openApiMetadataResource.IsDeprecated,
         consumes = new[]
         {
             _contentTypeStrategy.GetOperationContentType(
                 openApiMetadataResource,
                 ContentTypeUsage.Writable)
         },
         parameters = new List <Parameter>
         {
             new Parameter {
                 @ref = OpenApiMetadataDocumentHelper.GetParameterReference("offset")
             },
             new Parameter {
                 @ref = OpenApiMetadataDocumentHelper.GetParameterReference("limit")
             },
             new Parameter {
                 @ref = OpenApiMetadataDocumentHelper.GetParameterReference("MinChangeVersion")
             },
             new Parameter {
                 @ref = OpenApiMetadataDocumentHelper.GetParameterReference("MaxChangeVersion")
             }
         },
         responses = OpenApiMetadataDocumentHelper.GetReadOperationResponses(
             _pathsFactoryNamingStrategy.GetResourceName(openApiMetadataResource, ContentTypeUsage.Readable),
             true, true)
     });
 }
 private Operation CreateGetByIdOperation(OpenApiMetadataPathsResource openApiMetadataResource)
 {
     return(new Operation
     {
         tags = new List <string>
         {
             OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
             .ToCamelCase()
         },
         summary = "Retrieves a specific resource using the resource's identifier (using the \"Get By Id\" pattern).",
         description = "This GET operation retrieves a resource by the specified resource identifier.",
         operationId = $"get{openApiMetadataResource.Resource.PluralName}ById",
         deprecated = openApiMetadataResource.IsDeprecated,
         produces = new[]
         {
             _contentTypeStrategy.GetOperationContentType(openApiMetadataResource, ContentTypeUsage.Readable)
         },
         parameters = new[]
         {
             // Path parameters need to be inline in the operation, and not referenced.
             OpenApiMetadataDocumentHelper.CreateIdParameter(),
             new Parameter {
                 @ref = OpenApiMetadataDocumentHelper.GetParameterReference("If-None-Match")
             }
         }.Concat(
             openApiMetadataResource.DefaultGetByIdParameters
             .Select(p => new Parameter {
             @ref = OpenApiMetadataDocumentHelper.GetParameterReference(p)
         }))
         .ToList(),
         responses =
             OpenApiMetadataDocumentHelper.GetReadOperationResponses(
                 _pathsFactoryNamingStrategy.GetResourceName(openApiMetadataResource, ContentTypeUsage.Readable),
                 false)
     });
 }
Esempio n. 5
0
        // NOTE: This adds the deletes get request for change queries.
        private Operation CreateDeletesOperation(OpenApiMetadataPathsResource openApiMetadataResource)
        {
            var responses = OpenApiMetadataDocumentHelper.GetReadOperationResponses(
                _pathsFactoryNamingStrategy.GetResourceName(openApiMetadataResource, ContentTypeUsage.Readable),
                true, true);

            var parameters = new List <Parameter>
            {
                new Parameter {
                    @ref = OpenApiMetadataDocumentHelper.GetParameterReference("offset")
                },
                new Parameter {
                    @ref = OpenApiMetadataDocumentHelper.GetParameterReference("limit")
                },
                new Parameter {
                    @ref = OpenApiMetadataDocumentHelper.GetParameterReference("MinChangeVersion")
                },
                new Parameter {
                    @ref = OpenApiMetadataDocumentHelper.GetParameterReference("MaxChangeVersion")
                }
            };

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                responses.Add(
                    "410",
                    new Response
                {
                    description =
                        "Gone. An attempt to connect to the database for the snapshot specified by the Snapshot-Identifier header was unsuccessful (indicating the snapshot may have been removed)."
                });

                parameters.Add(new Parameter {
                    name        = "Snapshot-Identifier",
                    @in         = "header",
                    description = "Indicates the Snapshot-Identifier that should be used.",
                    type        = "string",
                    required    = false
                });
            }

            return(new Operation
            {
                tags = new List <string>
                {
                    OpenApiMetadataDocumentHelper.GetResourcePluralName(openApiMetadataResource.Resource)
                    .ToCamelCase()
                },
                summary = "Retrieves deleted resources based on change version.",
                description = "The DELETES operation is used to retrieve deleted resources.",
                operationId = $"deletes{openApiMetadataResource.Resource.PluralName}",
                deprecated = openApiMetadataResource.IsDeprecated,
                consumes = new[]
                {
                    _contentTypeStrategy.GetOperationContentType(
                        openApiMetadataResource,
                        ContentTypeUsage.Writable)
                },
                parameters = parameters,
                responses = responses
            });
        }