- switches to a referenced schema for count operations

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
This commit is contained in:
Vincent Biret 2021-11-22 14:30:18 -05:00
parent 2fee91b384
commit 76cfc303bc
No known key found for this signature in database
GPG key ID: 32426322EDFFB7E3
3 changed files with 15 additions and 4 deletions

View file

@ -79,5 +79,9 @@ namespace Microsoft.OpenApi.OData.Common
/// extension for discriminator value support
/// </summary>
public static string xMsDiscriminatorValue = "x-ms-discriminator-value";
/// <summary>
/// Name used for the OpenAPI referenced schema for OData Count operations responses.
/// </summary>
public static string DollarCountSchemaName = "ODataCountResponse";
}
}

View file

@ -67,6 +67,11 @@ namespace Microsoft.OpenApi.OData.Generator
schemas[schema.Key] = schema.Value;
}
schemas[Constants.DollarCountSchemaName] = new OpenApiSchema {
Type = "integer",
Format = "int32"
};
return schemas;
}

View file

@ -54,10 +54,12 @@ namespace Microsoft.OpenApi.OData.Operation
/// <inheritdoc/>
protected override void SetResponses(OpenApiOperation operation)
{
OpenApiSchema schema = new OpenApiSchema
{
Type = "integer",
Format = "int32"
OpenApiSchema schema = new()
{
Reference = new() {
Type = ReferenceType.Schema,
Id = Constants.DollarCountSchemaName
}
};
operation.Responses = new OpenApiResponses