diff --git a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs index ee971b5..8bffc0a 100644 --- a/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs +++ b/src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs @@ -208,12 +208,18 @@ namespace Microsoft.OpenApi.OData.Generator } } - private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext context, IEdmStructuredType structuredType, bool processBase, bool processExample, + private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext context, IEdmStructuredType structuredType, bool processBase, bool processExample, IEnumerable derivedTypes = null) { Debug.Assert(context != null); Debug.Assert(structuredType != null); + IOpenApiAny example = null; + if (context.Settings.ShowSchemaExamples) + { + example = CreateStructuredTypePropertiesExample(context, structuredType); + } + if (context.Settings.EnableDiscriminatorValue && derivedTypes == null) { derivedTypes = context.Model.FindDirectlyDerivedTypes(structuredType).OfType(); @@ -256,7 +262,7 @@ namespace Microsoft.OpenApi.OData.Generator AnyOf = null, OneOf = null, Properties = null, - Example = CreateStructuredTypePropertiesExample(context, structuredType) + Example = example }; } else @@ -305,7 +311,7 @@ namespace Microsoft.OpenApi.OData.Generator if (processExample) { - schema.Example = CreateStructuredTypePropertiesExample(context, structuredType); + schema.Example = example; } return schema; diff --git a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs index e61061f..b7c2c4b 100644 --- a/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs +++ b/src/Microsoft.OpenApi.OData.Reader/OpenApiConvertSettings.cs @@ -125,6 +125,11 @@ namespace Microsoft.OpenApi.OData /// public bool ShowLinks { get; set; } = false; + /// + /// Gets/Sets a value indicating whether or not to show schema examples. + /// + public bool ShowSchemaExamples { get; set; } = false; + internal OpenApiConvertSettings Clone() { var newSettings = new OpenApiConvertSettings @@ -150,7 +155,8 @@ namespace Microsoft.OpenApi.OData EnableDerivedTypesReferencesForResponses = this.EnableDerivedTypesReferencesForResponses, EnableDerivedTypesReferencesForRequestBody = this.EnableDerivedTypesReferencesForRequestBody, PathPrefix = this.PathPrefix, - ShowLinks = this.ShowLinks + ShowLinks = this.ShowLinks, + ShowSchemaExamples = this.ShowSchemaExamples }; return newSettings; diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs index a8c8423..ebb661c 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/EdmModelOpenApiExtensionsTest.cs @@ -88,8 +88,11 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.BasicEdmModel; - var openApiConvertSettings = new OpenApiConvertSettings(); - openApiConvertSettings.OpenApiSpecVersion = specVersion; + var openApiConvertSettings = new OpenApiConvertSettings + { + OpenApiSpecVersion = specVersion, + ShowSchemaExamples = true // test for schema examples + }; // Act string json = WriteEdmModelAsOpenApi(model, OpenApiFormat.Json, openApiConvertSettings); @@ -113,8 +116,11 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.BasicEdmModel; - var openApiConvertSettings = new OpenApiConvertSettings(); - openApiConvertSettings.OpenApiSpecVersion = specVersion; + var openApiConvertSettings = new OpenApiConvertSettings + { + OpenApiSpecVersion = specVersion, + ShowSchemaExamples = true + }; // Act string yaml = WriteEdmModelAsOpenApi(model, OpenApiFormat.Yaml, openApiConvertSettings); @@ -138,9 +144,12 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.MultipleSchemasEdmModel; - var openApiConvertSettings = new OpenApiConvertSettings(); - openApiConvertSettings.OpenApiSpecVersion = specVersion; - openApiConvertSettings.ShowLinks = true; // test Links + var openApiConvertSettings = new OpenApiConvertSettings + { + OpenApiSpecVersion = specVersion, + ShowLinks = true, // test Links + ShowSchemaExamples = true + }; // Act string json = WriteEdmModelAsOpenApi(model, OpenApiFormat.Json, openApiConvertSettings); @@ -164,9 +173,12 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.MultipleSchemasEdmModel; - var openApiConvertSettings = new OpenApiConvertSettings(); - openApiConvertSettings.OpenApiSpecVersion = specVersion; - openApiConvertSettings.ShowLinks = true; // test Links + var openApiConvertSettings = new OpenApiConvertSettings + { + OpenApiSpecVersion = specVersion, + ShowLinks = true, // test Links + ShowSchemaExamples = true + }; // Act string yaml = WriteEdmModelAsOpenApi(model, OpenApiFormat.Yaml, openApiConvertSettings); diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs index 6756d79..4d975d8 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs @@ -61,7 +61,10 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.MultipleInheritanceEdmModel; - ODataContext context = new ODataContext(model); + ODataContext context = new ODataContext(model, new OpenApiConvertSettings + { + ShowSchemaExamples = true + }); IEdmComplexType complex = model.SchemaElements.OfType().First(t => t.Name == "Address"); Assert.NotNull(complex); // Guard @@ -112,7 +115,8 @@ namespace Microsoft.OpenApi.OData.Tests IEdmModel model = EdmModelHelper.MultipleInheritanceEdmModel; ODataContext context = new ODataContext(model, new OpenApiConvertSettings { - IEEE754Compatible = true + IEEE754Compatible = true, + ShowSchemaExamples = true }); IEdmComplexType complex = model.SchemaElements.OfType().First(t => t.Name == "Tree"); Assert.NotNull(complex); // Guard @@ -201,7 +205,10 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.MultipleInheritanceEdmModel; - ODataContext context = new ODataContext(model); + ODataContext context = new ODataContext(model, new OpenApiConvertSettings + { + ShowSchemaExamples = true + }); IEdmEntityType entity = model.SchemaElements.OfType().First(t => t.Name == "Zoo"); Assert.NotNull(entity); // Guard @@ -258,7 +265,10 @@ namespace Microsoft.OpenApi.OData.Tests { // Arrange IEdmModel model = EdmModelHelper.MultipleInheritanceEdmModel; - ODataContext context = new ODataContext(model); + ODataContext context = new ODataContext(model, new OpenApiConvertSettings + { + ShowSchemaExamples = true + }); IEdmEntityType entity = model.SchemaElements.OfType().First(t => t.Name == "Human"); Assert.NotNull(entity); // Guard diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.json b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.json index 14ffda5..711b8c7 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.json +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.json @@ -4818,48 +4818,6 @@ "$ref": "#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" } } - }, - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ] } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline": { @@ -4872,10 +4830,6 @@ "Name": { "type": "string" } - }, - "example": { - "AirlineCode": "string (identifier)", - "Name": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport": { @@ -4894,14 +4848,6 @@ "Location": { "$ref": "#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation" } - }, - "example": { - "Name": "string", - "IcaoCode": "string (identifier)", - "IataCode": "string", - "Location": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation" - } } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location": { @@ -4914,12 +4860,6 @@ "City": { "$ref": "#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" } - }, - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - } } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City": { @@ -4935,11 +4875,6 @@ "Region": { "type": "string" } - }, - "example": { - "Name": "string", - "CountryRegion": "string", - "Region": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation": { @@ -4956,14 +4891,7 @@ } } } - ], - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - }, - "Loc": "Edm.GeographyPoint" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation": { "allOf": [ @@ -4979,14 +4907,7 @@ } } } - ], - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - }, - "BuildingInfo": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip": { "title": "Trip", @@ -5034,23 +4955,6 @@ "$ref": "#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem" } } - }, - "example": { - "TripId": "integer (identifier)", - "ShareId": "string", - "Name": "string", - "Budget": "float", - "Description": "string", - "Tags": [ - "string" - ], - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "PlanItems": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem" - } - ] } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem": { @@ -5081,13 +4985,6 @@ "pattern": "^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$", "type": "string" } - }, - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Event": { @@ -5107,18 +5004,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "OccursAt": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation" - }, - "Description": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation": { "allOf": [ @@ -5134,15 +5020,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "SeatNumber": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight": { "allOf": [ @@ -5167,25 +5045,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "SeatNumber": "string", - "FlightNumber": "string", - "Airline": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline" - }, - "From": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport" - }, - "To": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport" - } - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee": { "allOf": [ @@ -5207,55 +5067,7 @@ } } } - ], - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ], - "Cost": "int64", - "Peers": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ] - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Manager": { "allOf": [ @@ -5280,58 +5092,7 @@ } } } - ], - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ], - "Budget": "int64", - "BossOffice": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "DirectReports": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ] - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender": { "title": "PersonGender", diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.yaml b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.yaml index 29bc584..0cb2eff 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.yaml +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.yaml @@ -3352,30 +3352,6 @@ definitions: type: array items: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline: title: Airline type: object @@ -3384,9 +3360,6 @@ definitions: type: string Name: type: string - example: - AirlineCode: string (identifier) - Name: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport: title: Airport type: object @@ -3399,12 +3372,6 @@ definitions: type: string Location: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation' - example: - Name: string - IcaoCode: string (identifier) - IataCode: string - Location: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location: title: Location type: object @@ -3413,10 +3380,6 @@ definitions: type: string City: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.City' - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City Microsoft.OData.Service.Sample.TrippinInMemory.Models.City: title: City type: object @@ -3427,10 +3390,6 @@ definitions: type: string Region: type: string - example: - Name: string - CountryRegion: string - Region: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' @@ -3439,11 +3398,6 @@ definitions: properties: Loc: $ref: '#/definitions/Edm.GeographyPoint' - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City - Loc: Edm.GeographyPoint Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' @@ -3452,11 +3406,6 @@ definitions: properties: BuildingInfo: type: string - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City - BuildingInfo: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip: title: Trip type: object @@ -3492,18 +3441,6 @@ definitions: type: array items: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' - example: - TripId: integer (identifier) - ShareId: string - Name: string - Budget: float - Description: string - Tags: - - string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - PlanItems: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem: title: PlanItem type: object @@ -3527,12 +3464,6 @@ definitions: format: duration pattern: '^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$' type: string - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Event: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' @@ -3543,15 +3474,6 @@ definitions: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation' Description: type: string - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - OccursAt: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation - Description: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' @@ -3560,13 +3482,6 @@ definitions: properties: SeatNumber: type: string - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - SeatNumber: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation' @@ -3581,20 +3496,6 @@ definitions: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport' To: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport' - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - SeatNumber: string - FlightNumber: string - Airline: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline - From: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport - To: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' @@ -3607,33 +3508,6 @@ definitions: type: array items: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip - Cost: int64 - Peers: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person Microsoft.OData.Service.Sample.TrippinInMemory.Models.Manager: allOf: - $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' @@ -3648,35 +3522,6 @@ definitions: type: array items: $ref: '#/definitions/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip - Budget: int64 - BossOffice: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - DirectReports: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender: title: PersonGender enum: diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json index 916a249..2d30623 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json @@ -5470,48 +5470,6 @@ "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" } } - }, - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ] } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline": { @@ -5525,10 +5483,6 @@ "type": "string", "nullable": true } - }, - "example": { - "AirlineCode": "string (identifier)", - "Name": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport": { @@ -5554,14 +5508,6 @@ ], "nullable": true } - }, - "example": { - "Name": "string", - "IcaoCode": "string (identifier)", - "IataCode": "string", - "Location": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation" - } } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location": { @@ -5580,12 +5526,6 @@ ], "nullable": true } - }, - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - } } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City": { @@ -5604,11 +5544,6 @@ "type": "string", "nullable": true } - }, - "example": { - "Name": "string", - "CountryRegion": "string", - "Region": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation": { @@ -5625,14 +5560,7 @@ } } } - ], - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - }, - "Loc": "Edm.GeographyPoint" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation": { "allOf": [ @@ -5649,14 +5577,7 @@ } } } - ], - "example": { - "Address": "string", - "City": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.City" - }, - "BuildingInfo": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip": { "title": "Trip", @@ -5722,23 +5643,6 @@ "$ref": "#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem" } } - }, - "example": { - "TripId": "integer (identifier)", - "ShareId": "string", - "Name": "string", - "Budget": "float", - "Description": "string", - "Tags": [ - "string" - ], - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "PlanItems": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem" - } - ] } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem": { @@ -5770,13 +5674,6 @@ "type": "string", "format": "duration" } - }, - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string" } }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Event": { @@ -5802,18 +5699,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "OccursAt": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation" - }, - "Description": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation": { "allOf": [ @@ -5830,15 +5716,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "SeatNumber": "string" - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight": { "allOf": [ @@ -5879,25 +5757,7 @@ } } } - ], - "example": { - "PlanItemId": "integer (identifier)", - "ConfirmationCode": "string", - "StartsAt": "string (timestamp)", - "EndsAt": "string (timestamp)", - "Duration": "string", - "SeatNumber": "string", - "FlightNumber": "string", - "Airline": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline" - }, - "From": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport" - }, - "To": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport" - } - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee": { "allOf": [ @@ -5927,55 +5787,7 @@ } } } - ], - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ], - "Cost": "int64", - "Peers": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ] - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Manager": { "allOf": [ @@ -6013,58 +5825,7 @@ } } } - ], - "example": { - "UserName": "string (identifier)", - "FirstName": "string", - "LastName": "string", - "MiddleName": "string", - "Gender": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender" - }, - "Age": "int64", - "Emails": [ - "string" - ], - "AddressInfo": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - } - ], - "HomeAddress": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "FavoriteFeature": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - }, - "Features": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature" - } - ], - "Friends": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ], - "BestFriend": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - }, - "Trips": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip" - } - ], - "Budget": "int64", - "BossOffice": { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location" - }, - "DirectReports": [ - { - "@odata.type": "Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person" - } - ] - } + ] }, "Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender": { "title": "PersonGender", diff --git a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml index 70de43c..ec59ccc 100644 --- a/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml +++ b/test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml @@ -3719,30 +3719,6 @@ components: type: array items: $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline: title: Airline type: object @@ -3752,9 +3728,6 @@ components: Name: type: string nullable: true - example: - AirlineCode: string (identifier) - Name: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport: title: Airport type: object @@ -3771,12 +3744,6 @@ components: anyOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation' nullable: true - example: - Name: string - IcaoCode: string (identifier) - IataCode: string - Location: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location: title: Location type: object @@ -3788,10 +3755,6 @@ components: anyOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.City' nullable: true - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City Microsoft.OData.Service.Sample.TrippinInMemory.Models.City: title: City type: object @@ -3805,10 +3768,6 @@ components: Region: type: string nullable: true - example: - Name: string - CountryRegion: string - Region: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' @@ -3817,11 +3776,6 @@ components: properties: Loc: $ref: '#/components/schemas/Edm.GeographyPoint' - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City - Loc: Edm.GeographyPoint Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location' @@ -3831,11 +3785,6 @@ components: BuildingInfo: type: string nullable: true - example: - Address: string - City: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.City - BuildingInfo: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip: title: Trip type: object @@ -3881,18 +3830,6 @@ components: type: array items: $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' - example: - TripId: integer (identifier) - ShareId: string - Name: string - Budget: float - Description: string - Tags: - - string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - PlanItems: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem: title: PlanItem type: object @@ -3917,12 +3854,6 @@ components: pattern: '^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+([.][0-9]+)?S)?)?$' type: string format: duration - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Event: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' @@ -3936,15 +3867,6 @@ components: Description: type: string nullable: true - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - OccursAt: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.EventLocation - Description: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PlanItem' @@ -3954,13 +3876,6 @@ components: SeatNumber: type: string nullable: true - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - SeatNumber: string Microsoft.OData.Service.Sample.TrippinInMemory.Models.Flight: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.PublicTransportation' @@ -3982,20 +3897,6 @@ components: anyOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport' nullable: true - example: - PlanItemId: integer (identifier) - ConfirmationCode: string - StartsAt: string (timestamp) - EndsAt: string (timestamp) - Duration: string - SeatNumber: string - FlightNumber: string - Airline: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airline - From: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport - To: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Airport Microsoft.OData.Service.Sample.TrippinInMemory.Models.Employee: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' @@ -4011,33 +3912,6 @@ components: type: array items: $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip - Cost: int64 - Peers: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person Microsoft.OData.Service.Sample.TrippinInMemory.Models.Manager: allOf: - $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' @@ -4057,35 +3931,6 @@ components: type: array items: $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person' - example: - UserName: string (identifier) - FirstName: string - LastName: string - MiddleName: string - Gender: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender - Age: int64 - Emails: - - string - AddressInfo: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - HomeAddress: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - FavoriteFeature: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Features: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Feature - Friends: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - BestFriend: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person - Trips: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Trip - Budget: int64 - BossOffice: - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Location - DirectReports: - - '@odata.type': Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person Microsoft.OData.Service.Sample.TrippinInMemory.Models.PersonGender: title: PersonGender enum: