Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds odata metadata to entity type #74

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/TripPin.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,9 @@
"title": "EventLocation",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"Address": {
"type": "string"
},
Expand All @@ -3380,6 +3383,9 @@
"title": "EventLocation (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"Address": {
"type": "string"
},
Expand Down Expand Up @@ -3412,6 +3418,9 @@
"title": "AirportLocation",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"Address": {
"type": "string"
},
Expand All @@ -3427,6 +3436,9 @@
"title": "AirportLocation (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"Address": {
"type": "string"
},
Expand Down Expand Up @@ -3846,6 +3858,9 @@
"title": "PublicTransportation",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"PlanItemId": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3888,6 +3903,9 @@
"title": "PublicTransportation (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ConfirmationCode": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -3964,6 +3982,9 @@
"title": "Flight",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"PlanItemId": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -4012,6 +4033,9 @@
"title": "Flight (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ConfirmationCode": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -4091,6 +4115,9 @@
"title": "Event",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"PlanItemId": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -4130,6 +4157,9 @@
"title": "Event (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ConfirmationCode": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -4408,6 +4438,9 @@
"type": "number"
}
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
3 changes: 3 additions & 0 deletions examples/annotations.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to not have this „reuse schema“, or only have it when it isn’t needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this function deleteUnreferencedSchemas which has the desired effect. But it also removes a lot of other unused schemas causing a bunch of tests to fail. Fixable though.

But I assume deleteUnreferencedSchemas wasn't used for a reason?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason is that there can be CSDL files with schemas for reusable types and no entity container. The types are only referenced from other files, not from within the same file.

Consequently "delete unreferenced schemas" is not on by default.

Easiest fix here is not to define a reuse schema and generate @type directly with type: "string".

"error": {
"type": "object",
"required": [
Expand Down
3 changes: 3 additions & 0 deletions examples/authorization.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
3 changes: 3 additions & 0 deletions examples/containment.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -5189,6 +5189,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
3 changes: 3 additions & 0 deletions examples/csdl-16.1.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
3 changes: 3 additions & 0 deletions examples/descriptions.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
21 changes: 21 additions & 0 deletions examples/example.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,9 @@
"title": "FeaturedProduct",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3309,6 +3312,9 @@
"title": "FeaturedProduct (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3819,6 +3825,9 @@
"title": "Customer",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3854,6 +3863,9 @@
"title": "Customer (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3915,6 +3927,9 @@
"title": "Employee",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -3966,6 +3981,9 @@
"title": "Employee (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "integer",
"format": "int32"
Expand Down Expand Up @@ -4280,6 +4298,9 @@
],
"description": "The number of entities in the collection. Available when using the [$count](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_SystemQueryOptioncount) query option."
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
25 changes: 25 additions & 0 deletions examples/miscellaneous.openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3380,6 +3380,9 @@
"title": "Manager",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "string"
},
Expand Down Expand Up @@ -3426,6 +3429,9 @@
"title": "Manager (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ID": {
"type": "string"
},
Expand Down Expand Up @@ -5903,10 +5909,20 @@
"type": "object"
},
"Y.DeveloperType": {
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
}
},
"title": "DeveloperType",
"type": "object"
},
"Y.DeveloperType-create": {
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
}
},
"title": "DeveloperType (for create)",
"type": "object"
},
Expand Down Expand Up @@ -5960,6 +5976,9 @@
"title": "ArchivedMovieType",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ArchivedAt": {
"type": "string",
"format": "date",
Expand All @@ -5972,6 +5991,9 @@
"title": "ArchivedMovieType (for create)",
"type": "object",
"properties": {
"@odata.type": {
"$ref": "#/components/schemas/type"
},
"ArchivedAt": {
"type": "string",
"format": "date",
Expand Down Expand Up @@ -6131,6 +6153,9 @@
"type": "number"
}
},
"type": {
"type": "string"
},
"error": {
"type": "object",
"required": [
Expand Down
Loading