Skip to content

Commit 76cfc30

Browse files
committed
- switches to a referenced schema for count operations
Signed-off-by: Vincent Biret <[email protected]>
1 parent 2fee91b commit 76cfc30

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Microsoft.OpenApi.OData.Reader/Common/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,9 @@ internal static class Constants
7979
/// extension for discriminator value support
8080
/// </summary>
8181
public static string xMsDiscriminatorValue = "x-ms-discriminator-value";
82+
/// <summary>
83+
/// Name used for the OpenAPI referenced schema for OData Count operations responses.
84+
/// </summary>
85+
public static string DollarCountSchemaName = "ODataCountResponse";
8286
}
8387
}

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public static IDictionary<string, OpenApiSchema> CreateSchemas(this ODataContext
6767
schemas[schema.Key] = schema.Value;
6868
}
6969

70+
schemas[Constants.DollarCountSchemaName] = new OpenApiSchema {
71+
Type = "integer",
72+
Format = "int32"
73+
};
74+
7075
return schemas;
7176
}
7277

src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ protected override void SetBasicInfo(OpenApiOperation operation)
5454
/// <inheritdoc/>
5555
protected override void SetResponses(OpenApiOperation operation)
5656
{
57-
OpenApiSchema schema = new OpenApiSchema
58-
{
59-
Type = "integer",
60-
Format = "int32"
57+
OpenApiSchema schema = new()
58+
{
59+
Reference = new() {
60+
Type = ReferenceType.Schema,
61+
Id = Constants.DollarCountSchemaName
62+
}
6163
};
6264

6365
operation.Responses = new OpenApiResponses

0 commit comments

Comments
 (0)