Skip to content

Commit aa6a60e

Browse files
Update key path parameter descriptions (#336)
* Update key path parameter descriptions * Update tests * Add release notes
1 parent c3d489d commit aa6a60e

15 files changed

+1471
-1552
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
180180
Name = parameterNameMapping == null ? keyName: parameterNameMapping[keyName],
181181
In = ParameterLocation.Path,
182182
Required = true,
183-
Description = "key: " + keyName + " of " + entityType.Name,
183+
Description = $"The unique identifier of {entityType.Name}",
184184
Schema = context.CreateEdmTypeSchema(keys.First().Type)
185185
};
186186

@@ -199,7 +199,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
199199
parameterNameMapping[keyProperty.Name],// By design: not prefix with type name if enable type name prefix
200200
In = ParameterLocation.Path,
201201
Required = true,
202-
Description = "key: " + keyProperty.Name + " of " + entityType.Name,
202+
Description = $"Property in multi-part unique identifier of {entityType.Name}",
203203
Schema = context.CreateEdmTypeSchema(keyProperty.Type)
204204
};
205205

@@ -229,7 +229,7 @@ private static IList<OpenApiParameter> CreateAlternateKeyParameters(ODataContext
229229
{
230230
Name = alternateKey.First().Key,
231231
In = ParameterLocation.Path,
232-
Description = $"Alternate key: {alternateKey.First().Value.Name} of {entityType.Name}",
232+
Description = $"Alternate key of {entityType.Name}",
233233
Schema = context.CreateEdmTypeSchema(alternateKey.First().Value.Type),
234234
Required = true
235235
}
@@ -244,7 +244,7 @@ private static IList<OpenApiParameter> CreateAlternateKeyParameters(ODataContext
244244
{
245245
Name = compositekey.Key,
246246
In = ParameterLocation.Path,
247-
Description = $"Composite alternate key: {compositekey.Value.Name} of {entityType.Name}",
247+
Description = $"Property in multi-part alternate key of {entityType.Name}",
248248
Schema = context.CreateEdmTypeSchema(compositekey.Value.Type),
249249
Required = true
250250
}

src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,13 @@
1515
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1616
<PackageId>Microsoft.OpenApi.OData</PackageId>
1717
<SignAssembly>true</SignAssembly>
18-
<Version>1.2.0</Version>
18+
<Version>1.3.0-preview1</Version>
1919
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
2020
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2121
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
2222
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET.OData</RepositoryUrl>
2323
<PackageReleaseNotes>
24-
- Use convert setting to toggle between referencing @odata.count and @odata.nextLink #282
25-
- Fixes URL Path parameters of type datetime generated as strings with quotes #262
26-
- Set assembly version used for conversion in OpenApiInfo object #208
27-
- Adds create and update operations to non-containment navigation properties when restrictions annotations are explicitly set to true #265
28-
- Generate odata.nextLink and odata.deltaLink properties on delta functions response schemas #285
29-
- Omits paths with PathItems without any operation #148
30-
- Expands navigation properties of derived types only if declaring navigation property is a containment #269
31-
- Adds custom parameters to $count and ODataTypeCast paths' Get operations #207
32-
- Adds support for configuring the default value of derived types' @odata.type property #304
33-
- Adds OData query parameters to $count endpoints #313
34-
- Finds all the derived types for a schema element #84
35-
- Add support for paths with alternate keys #120, #329
24+
- Update key path parameter descriptions #309
3625
</PackageReleaseNotes>
3726
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
3827
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>

test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiParameterGeneratorTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void CreateKeyParametersForSingleKeyWorks(bool prefix)
190190
expected = @"{
191191
""name"": ""Customer-Id"",
192192
""in"": ""path"",
193-
""description"": ""key: Customer-Id of Customer"",
193+
""description"": ""The unique identifier of Customer"",
194194
""required"": true,
195195
""schema"": {
196196
""type"": ""string"",
@@ -204,7 +204,7 @@ public void CreateKeyParametersForSingleKeyWorks(bool prefix)
204204
expected = @"{
205205
""name"": ""Id"",
206206
""in"": ""path"",
207-
""description"": ""key: Id of Customer"",
207+
""description"": ""The unique identifier of Customer"",
208208
""required"": true,
209209
""schema"": {
210210
""type"": ""string"",
@@ -248,7 +248,7 @@ public void CreateKeyParametersForCompositeKeyWorks(bool prefix)
248248
string expected = @"{
249249
""name"": ""firstName"",
250250
""in"": ""path"",
251-
""description"": ""key: firstName of Customer"",
251+
""description"": ""Property in multi-part unique identifier of Customer"",
252252
""required"": true,
253253
""schema"": {
254254
""type"": ""string"",
@@ -264,7 +264,7 @@ public void CreateKeyParametersForCompositeKeyWorks(bool prefix)
264264
expected = @"{
265265
""name"": ""lastName"",
266266
""in"": ""path"",
267-
""description"": ""key: lastName of Customer"",
267+
""description"": ""Property in multi-part unique identifier of Customer"",
268268
""required"": true,
269269
""schema"": {
270270
""type"": ""string"",
@@ -304,7 +304,7 @@ public void CreateKeyParametersForAlternateKeyWithSinglePropertyWorks()
304304
Assert.Equal(@"{
305305
""name"": ""AltId"",
306306
""in"": ""path"",
307-
""description"": ""Alternate key: AlternateId of Customer"",
307+
""description"": ""Alternate key of Customer"",
308308
""required"": true,
309309
""schema"": {
310310
""type"": ""string"",
@@ -349,7 +349,7 @@ public void CreateKeyParametersForAlternateKeyWithMultiplePropertiesWorks()
349349
Assert.Equal(@"{
350350
""name"": ""AltId1"",
351351
""in"": ""path"",
352-
""description"": ""Composite alternate key: AlternateId1 of Customer"",
352+
""description"": ""Property in multi-part alternate key of Customer"",
353353
""required"": true,
354354
""schema"": {
355355
""type"": ""string"",
@@ -361,7 +361,7 @@ public void CreateKeyParametersForAlternateKeyWithMultiplePropertiesWorks()
361361
Assert.Equal(@"{
362362
""name"": ""AltId2"",
363363
""in"": ""path"",
364-
""description"": ""Composite alternate key: AlternateId2 of Customer"",
364+
""description"": ""Property in multi-part alternate key of Customer"",
365365
""required"": true,
366366
""schema"": {
367367
""type"": ""string"",

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Basic.OpenApi.V2.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
{
133133
"in": "path",
134134
"name": "Name",
135-
"description": "key: Name of City",
135+
"description": "The unique identifier of City",
136136
"required": true,
137137
"type": "string",
138138
"x-ms-docs-key-type": "City"
@@ -188,7 +188,7 @@
188188
{
189189
"in": "path",
190190
"name": "Name",
191-
"description": "key: Name of City",
191+
"description": "The unique identifier of City",
192192
"required": true,
193193
"type": "string",
194194
"x-ms-docs-key-type": "City"
@@ -223,7 +223,7 @@
223223
{
224224
"in": "path",
225225
"name": "Name",
226-
"description": "key: Name of City",
226+
"description": "The unique identifier of City",
227227
"required": true,
228228
"type": "string",
229229
"x-ms-docs-key-type": "City"
@@ -392,7 +392,7 @@
392392
{
393393
"in": "path",
394394
"name": "Name",
395-
"description": "key: Name of CountryOrRegion",
395+
"description": "The unique identifier of CountryOrRegion",
396396
"required": true,
397397
"type": "string",
398398
"x-ms-docs-key-type": "CountryOrRegion"
@@ -448,7 +448,7 @@
448448
{
449449
"in": "path",
450450
"name": "Name",
451-
"description": "key: Name of CountryOrRegion",
451+
"description": "The unique identifier of CountryOrRegion",
452452
"required": true,
453453
"type": "string",
454454
"x-ms-docs-key-type": "CountryOrRegion"
@@ -483,7 +483,7 @@
483483
{
484484
"in": "path",
485485
"name": "Name",
486-
"description": "key: Name of CountryOrRegion",
486+
"description": "The unique identifier of CountryOrRegion",
487487
"required": true,
488488
"type": "string",
489489
"x-ms-docs-key-type": "CountryOrRegion"
@@ -746,7 +746,7 @@
746746
{
747747
"in": "path",
748748
"name": "UserName",
749-
"description": "key: UserName of Person",
749+
"description": "The unique identifier of Person",
750750
"required": true,
751751
"type": "string",
752752
"x-ms-docs-key-type": "Person"
@@ -805,7 +805,7 @@
805805
{
806806
"in": "path",
807807
"name": "UserName",
808-
"description": "key: UserName of Person",
808+
"description": "The unique identifier of Person",
809809
"required": true,
810810
"type": "string",
811811
"x-ms-docs-key-type": "Person"
@@ -840,7 +840,7 @@
840840
{
841841
"in": "path",
842842
"name": "UserName",
843-
"description": "key: UserName of Person",
843+
"description": "The unique identifier of Person",
844844
"required": true,
845845
"type": "string",
846846
"x-ms-docs-key-type": "Person"

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Basic.OpenApi.V2.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ paths:
8585
parameters:
8686
- in: path
8787
name: Name
88-
description: 'key: Name of City'
88+
description: The unique identifier of City
8989
required: true
9090
type: string
9191
x-ms-docs-key-type: City
@@ -123,7 +123,7 @@ paths:
123123
parameters:
124124
- in: path
125125
name: Name
126-
description: 'key: Name of City'
126+
description: The unique identifier of City
127127
required: true
128128
type: string
129129
x-ms-docs-key-type: City
@@ -147,7 +147,7 @@ paths:
147147
parameters:
148148
- in: path
149149
name: Name
150-
description: 'key: Name of City'
150+
description: The unique identifier of City
151151
required: true
152152
type: string
153153
x-ms-docs-key-type: City
@@ -253,7 +253,7 @@ paths:
253253
parameters:
254254
- in: path
255255
name: Name
256-
description: 'key: Name of CountryOrRegion'
256+
description: The unique identifier of CountryOrRegion
257257
required: true
258258
type: string
259259
x-ms-docs-key-type: CountryOrRegion
@@ -291,7 +291,7 @@ paths:
291291
parameters:
292292
- in: path
293293
name: Name
294-
description: 'key: Name of CountryOrRegion'
294+
description: The unique identifier of CountryOrRegion
295295
required: true
296296
type: string
297297
x-ms-docs-key-type: CountryOrRegion
@@ -315,7 +315,7 @@ paths:
315315
parameters:
316316
- in: path
317317
name: Name
318-
description: 'key: Name of CountryOrRegion'
318+
description: The unique identifier of CountryOrRegion
319319
required: true
320320
type: string
321321
x-ms-docs-key-type: CountryOrRegion
@@ -488,7 +488,7 @@ paths:
488488
parameters:
489489
- in: path
490490
name: UserName
491-
description: 'key: UserName of Person'
491+
description: The unique identifier of Person
492492
required: true
493493
type: string
494494
x-ms-docs-key-type: Person
@@ -529,7 +529,7 @@ paths:
529529
parameters:
530530
- in: path
531531
name: UserName
532-
description: 'key: UserName of Person'
532+
description: The unique identifier of Person
533533
required: true
534534
type: string
535535
x-ms-docs-key-type: Person
@@ -553,7 +553,7 @@ paths:
553553
parameters:
554554
- in: path
555555
name: UserName
556-
description: 'key: UserName of Person'
556+
description: The unique identifier of Person
557557
required: true
558558
type: string
559559
x-ms-docs-key-type: Person

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/Basic.OpenApi.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
{
145145
"name": "Name",
146146
"in": "path",
147-
"description": "key: Name of City",
147+
"description": "The unique identifier of City",
148148
"required": true,
149149
"schema": {
150150
"type": "string"
@@ -213,7 +213,7 @@
213213
{
214214
"name": "Name",
215215
"in": "path",
216-
"description": "key: Name of City",
216+
"description": "The unique identifier of City",
217217
"required": true,
218218
"schema": {
219219
"type": "string"
@@ -252,7 +252,7 @@
252252
{
253253
"name": "Name",
254254
"in": "path",
255-
"description": "key: Name of City",
255+
"description": "The unique identifier of City",
256256
"required": true,
257257
"schema": {
258258
"type": "string"
@@ -435,7 +435,7 @@
435435
{
436436
"name": "Name",
437437
"in": "path",
438-
"description": "key: Name of CountryOrRegion",
438+
"description": "The unique identifier of CountryOrRegion",
439439
"required": true,
440440
"schema": {
441441
"type": "string"
@@ -504,7 +504,7 @@
504504
{
505505
"name": "Name",
506506
"in": "path",
507-
"description": "key: Name of CountryOrRegion",
507+
"description": "The unique identifier of CountryOrRegion",
508508
"required": true,
509509
"schema": {
510510
"type": "string"
@@ -543,7 +543,7 @@
543543
{
544544
"name": "Name",
545545
"in": "path",
546-
"description": "key: Name of CountryOrRegion",
546+
"description": "The unique identifier of CountryOrRegion",
547547
"required": true,
548548
"schema": {
549549
"type": "string"
@@ -828,7 +828,7 @@
828828
{
829829
"name": "UserName",
830830
"in": "path",
831-
"description": "key: UserName of Person",
831+
"description": "The unique identifier of Person",
832832
"required": true,
833833
"schema": {
834834
"type": "string"
@@ -900,7 +900,7 @@
900900
{
901901
"name": "UserName",
902902
"in": "path",
903-
"description": "key: UserName of Person",
903+
"description": "The unique identifier of Person",
904904
"required": true,
905905
"schema": {
906906
"type": "string"
@@ -939,7 +939,7 @@
939939
{
940940
"name": "UserName",
941941
"in": "path",
942-
"description": "key: UserName of Person",
942+
"description": "The unique identifier of Person",
943943
"required": true,
944944
"schema": {
945945
"type": "string"

0 commit comments

Comments
 (0)