private IList <Parameter> CreateQueryParameters() { var parameterList = new List <Parameter> { new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("offset") }, new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("limit") } }; if (ChangeQueryFeature.IsEnabled) { parameterList.Add( new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("MinChangeVersion") }); parameterList.Add( new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("MaxChangeVersion") }); } if (_swaggerPathsFactorySelectorStrategy.HasTotalCount) { parameterList.Add( new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("totalCount") }); } return(parameterList); }
private IList <Parameter> CreateGetByExampleParameters(SwaggerPathsResource swaggerResource) { var parameterList = CreateQueryParameters() .Concat( swaggerResource.DefaultGetByExampleParameters.Select( p => new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference(p) })) .ToList(); swaggerResource.RequestProperties.ForEach( x => { parameterList.Add( new Parameter { name = x.PropertyName.ToCamelCase(), @in = swaggerResource.IsPathParameter(x) ? "path" : "query", description = SwaggerDocumentHelper.PropertyDescription(x), type = SwaggerDocumentHelper.PropertyType(x), format = x.PropertyType.ToOpenApiFormat(), required = swaggerResource.IsPathParameter(x), isIdentity = SwaggerDocumentHelper.GetIsIdentity(x), maxLength = SwaggerDocumentHelper.GetMaxLength(x), isDeprecated = SwaggerDocumentHelper.GetIsDeprecated(x), deprecatedReasons = SwaggerDocumentHelper.GetDeprecatedReasons(x) }); }); return(parameterList); }
private Operation CreateGetByIdOperation(SwaggerPathsResource swaggerResource) { return(new Operation { tags = new List <string> { SwaggerDocumentHelper.GetResourcePluralName(swaggerResource.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{swaggerResource.Resource.PluralName}ById", deprecated = swaggerResource.IsDeprecated, produces = new[] { _contentTypeStrategy.GetOperationContentType(swaggerResource, ContentTypeUsage.Readable) }, parameters = new[] { // Path parameters need to be inline in the operation, and not referenced. SwaggerDocumentHelper.CreateIdParameter(), new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("If-None-Match") } }.Concat( swaggerResource.DefaultGetByIdParameters .Select(p => new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference(p) })) .ToList(), responses = SwaggerDocumentHelper.GetReadOperationResponses( _pathsFactoryNamingStrategy.GetResourceName(swaggerResource, ContentTypeUsage.Readable), false) }); }
private Operation CreateDeletesOperation(SwaggerPathsResource swaggerResource) { return(new Operation { tags = new List <string> { SwaggerDocumentHelper.GetResourcePluralName(swaggerResource.Resource) .ToCamelCase() }, summary = "Retrieves deleted resources based on change version.", description = "The DELETES operation is used to retrieve deleted resources.", operationId = $"deletes{swaggerResource.Resource.PluralName}", deprecated = swaggerResource.IsDeprecated, consumes = new[] { _contentTypeStrategy.GetOperationContentType( swaggerResource, ContentTypeUsage.Writable) }, parameters = new List <Parameter> { new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("offset") }, new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("limit") }, new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("MinChangeVersion") }, new Parameter { @ref = SwaggerDocumentHelper.GetParameterReference("MaxChangeVersion") } }, responses = SwaggerDocumentHelper.GetReadOperationResponses( _pathsFactoryNamingStrategy.GetResourceName(swaggerResource, ContentTypeUsage.Readable), true) }); }