-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: UI OpenApi generator fails to create a proper Feed's discriminat…
…or (#555)
- Loading branch information
1 parent
85b283b
commit 19c9f71
Showing
9 changed files
with
268 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Verify TypeScript Types Generation | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- "docs/DatabaseCatalogAPI.yaml" | ||
|
||
env: | ||
NODE_VERSION: "18" | ||
|
||
jobs: | ||
generate-and-compare: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
cache: 'yarn' | ||
cache-dependency-path: 'web-app/yarn.lock' | ||
|
||
- name: Cache Yarn dependencies | ||
uses: actions/cache@v4 | ||
id: yarn-cache | ||
with: | ||
path: | | ||
**/node_modules | ||
**/.eslintcache | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('web-app/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
working-directory: web-app | ||
run: yarn install --frozen-lockfile --prefer-offline | ||
|
||
- name: Generate TypeScript types | ||
working-directory: web-app | ||
run: yarn generate:api-types:output | ||
env: | ||
OUTPUT_PATH_TYPES: src/app/services/feeds/generated/types.ts | ||
|
||
- name: Compare TypeScript types with existing types | ||
working-directory: web-app | ||
run: diff src/app/services/feeds/generated/types.ts src/app/services/feeds/types.ts || (echo "Types are different!" && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...h_feeds200_response_results_inner_impl.py → ...pl/models/search_feed_item_result_impl.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,10 +296,7 @@ paths: | |
results: | ||
type: array | ||
items: | ||
allOf: | ||
- $ref: '#/components/schemas/GtfsFeed' | ||
- $ref: '#/components/schemas/GtfsRTFeed' | ||
|
||
$ref: "#/components/schemas/SearchFeedItemResult" | ||
|
||
components: | ||
schemas: | ||
|
@@ -316,6 +313,11 @@ components: | |
example: Redirected because of a change of URL. | ||
BasicFeed: | ||
type: object | ||
discriminator: | ||
propertyName: data_type | ||
mapping: | ||
gtfs: '#/components/schemas/GtfsFeed' | ||
gtfs_rt: '#/components/schemas/GtfsRTFeed' | ||
properties: | ||
id: | ||
description: Unique identifier used as a key for the feeds table. | ||
|
@@ -350,7 +352,6 @@ components: | |
type: string | ||
example: 2023-07-10T22:06:00Z | ||
format: date-time | ||
|
||
external_ids: | ||
$ref: "#/components/schemas/ExternalIds" | ||
provider: | ||
|
@@ -418,6 +419,103 @@ components: | |
locations: | ||
$ref: "#/components/schemas/Locations" | ||
|
||
SearchFeedItemResult: | ||
# The following schema is used to represent the search results for feeds. | ||
# The schema is a union of all the possible types(BasicFeed, GtfsFeed and GtfsRTFeed) of feeds that can be returned. | ||
# This union is not based on its original types due to the limitations of openapi-generator. | ||
# For the same reason it's not defined as anyOf, but as a single object with all the possible properties. | ||
type: object | ||
required: | ||
- id | ||
- data_type | ||
- status | ||
properties: | ||
id: | ||
description: Unique identifier used as a key for the feeds table. | ||
type: string | ||
example: mdb-1210 | ||
data_type: | ||
type: string | ||
enum: | ||
- gtfs | ||
- gtfs_rt | ||
example: gtfs | ||
# Have to put the enum inline because of a bug in openapi-generator | ||
# $ref: "#/components/schemas/DataType" | ||
status: | ||
description: > | ||
Describes status of the Feed. Should be one of | ||
* `active` Feed should be used in public trip planners. | ||
* `deprecated` Feed is explicitly deprecated and should not be used in public trip planners. | ||
* `inactive` Feed hasn't been recently updated and should be used at risk of providing outdated information. | ||
* `development` Feed is being used for development purposes and should not be used in public trip planners. | ||
type: string | ||
enum: | ||
- active | ||
- deprecated | ||
- inactive | ||
- development | ||
example: deprecated | ||
# Have to put the enum inline because of a bug in openapi-generator | ||
# $ref: "#/components/schemas/FeedStatus" | ||
created_at: | ||
description: The date and time the feed was added to the database, in ISO 8601 date-time format. | ||
type: string | ||
example: 2023-07-10T22:06:00Z | ||
format: date-time | ||
external_ids: | ||
$ref: "#/components/schemas/ExternalIds" | ||
provider: | ||
description: A commonly used name for the transit provider included in the feed. | ||
type: string | ||
example: Los Angeles Department of Transportation (LADOT, DASH, Commuter Express) | ||
feed_name: | ||
description: > | ||
An optional description of the data feed, e.g to specify if the data feed is an aggregate of | ||
multiple providers, or which network is represented by the feed. | ||
type: string | ||
example: Bus | ||
note: | ||
description: A note to clarify complex use cases for consumers. | ||
type: string | ||
feed_contact_email: | ||
description: Use to contact the feed producer. | ||
type: string | ||
example: [email protected] | ||
source_info: | ||
$ref: "#/components/schemas/SourceInfo" | ||
redirects: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Redirect" | ||
locations: | ||
$ref: "#/components/schemas/Locations" | ||
latest_dataset: | ||
$ref: "#/components/schemas/LatestDataset" | ||
entity_types: | ||
type: array | ||
items: | ||
type: string | ||
enum: | ||
- vp | ||
- tu | ||
- sa | ||
example: vp | ||
description: > | ||
The type of realtime entry: | ||
* vp - vehicle positions | ||
* tu - trip updates | ||
* sa - service alerts | ||
# Have to put the enum inline because of a bug in openapi-generator | ||
# $ref: "#/components/schemas/EntityTypes" | ||
feed_references: | ||
description: | ||
A list of the GTFS feeds that the real time source is associated with, represented by their MDB source IDs. | ||
type: array | ||
items: | ||
type: string | ||
example: "mdb-20" | ||
|
||
BasicFeeds: | ||
type: array | ||
items: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.