private IList <Parameter> CreateGetByExampleParameters(OpenApiMetadataPathsResource openApiMetadataResource,
                                                               bool isCompositeContext)
        {
            var parameterList = CreateQueryParameters(isCompositeContext)
                                .Concat(
                openApiMetadataResource.DefaultGetByExampleParameters.Select(
                    p => new Parameter {
                @ref = OpenApiMetadataDocumentHelper.GetParameterReference(p)
            }))
                                .ToList();

            IEnumerableExtensions.ForEach(
                openApiMetadataResource.RequestProperties, x =>
            {
                parameterList.Add(
                    new Parameter
                {
                    name = StringExtensions.ToCamelCase(x.PropertyName),
                    @in  = openApiMetadataResource.IsPathParameter(x)
                                ? "path"
                                : "query",
                    description       = OpenApiMetadataDocumentHelper.PropertyDescription(x),
                    type              = OpenApiMetadataDocumentHelper.PropertyType(x),
                    format            = x.PropertyType.ToOpenApiFormat(),
                    required          = openApiMetadataResource.IsPathParameter(x),
                    isIdentity        = OpenApiMetadataDocumentHelper.GetIsIdentity(x),
                    maxLength         = OpenApiMetadataDocumentHelper.GetMaxLength(x),
                    isDeprecated      = OpenApiMetadataDocumentHelper.GetIsDeprecated(x),
                    deprecatedReasons = OpenApiMetadataDocumentHelper.GetDeprecatedReasons(x)
                });
            });

            return(parameterList);
        }
示例#2
0
        private IList <Parameter> CreateGetByExampleParameters(OpenApiMetadataPathsResource openApiMetadataResource,
                                                               bool isCompositeContext)
        {
            var parameterList = CreateQueryParameters(isCompositeContext)
                                .Concat(
                openApiMetadataResource.DefaultGetByExampleParameters.Select(
                    p => new Parameter {
                @ref = OpenApiMetadataDocumentHelper.GetParameterReference(p)
            }))
                                .ToList();

            IEnumerableExtensions.ForEach(
                openApiMetadataResource.RequestProperties, x =>
            {
                parameterList.Add(
                    new Parameter
                {
                    name = StringExtensions.ToCamelCase(x.PropertyName),
                    @in  = openApiMetadataResource.IsPathParameter(x)
                                ? "path"
                                : "query",
                    description       = OpenApiMetadataDocumentHelper.PropertyDescription(x),
                    type              = OpenApiMetadataDocumentHelper.PropertyType(x),
                    format            = x.PropertyType.ToOpenApiFormat(),
                    required          = openApiMetadataResource.IsPathParameter(x),
                    isIdentity        = OpenApiMetadataDocumentHelper.GetIsIdentity(x),
                    maxLength         = OpenApiMetadataDocumentHelper.GetMaxLength(x),
                    isDeprecated      = OpenApiMetadataDocumentHelper.GetIsDeprecated(x),
                    deprecatedReasons = OpenApiMetadataDocumentHelper.GetDeprecatedReasons(x)
                });
            });

            if (_apiSettings.IsFeatureEnabled(ApiFeature.ChangeQueries.GetConfigKeyName()))
            {
                parameterList.Add(new Parameter
                {
                    name        = "Snapshot-Identifier",
                    @in         = "header",
                    description = "Indicates the Snapshot-Identifier that should be used.",
                    type        = "string",
                    required    = false
                });
            }

            return(parameterList);
        }