Skip to content

Commit c1fdd19

Browse files
authored
Merge pull request #14 from openTdataCH/feature/ojp-response
Dynamic OJP response
2 parents a2ecb1d + 1553ec1 commit c1fdd19

55 files changed

Lines changed: 10004 additions & 1425 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.editorconfig‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

‎.env‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎.github/workflows/deploy-pages.yml‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy Angular to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Pages
22+
uses: actions/configure-pages@v5
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 22
28+
cache: npm
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Inject secrets
34+
run: |
35+
sed -i "s|PLACEHOLDER_REPLACE_TOKEN__formation|${{ secrets.API_KEY_FORMATION_SERVICE }}|g" \
36+
src/app/config/api-tokens.ts
37+
sed -i "s|PLACEHOLDER_REPLACE_TOKEN__ojp1|${{ secrets.API_KEY_OJP1 }}|g" \
38+
src/app/config/api-tokens.ts
39+
sed -i "s|PLACEHOLDER_REPLACE_TOKEN__ojp2|${{ secrets.API_KEY_OJP2 }}|g" \
40+
src/app/config/api-tokens.ts
41+
sed -i "s|PLACEHOLDER_REPLACE_TOKEN__ojp_fare|${{ secrets.API_KEY_OJPFARE }}|g" \
42+
src/app/config/api-tokens.ts
43+
sed -i "s|PLACEHOLDER_REPLACE_TOKEN__traffic_lights|${{ secrets.API_KEY_TRAFFIC_LIGHTS }}|g" \
44+
src/app/config/api-tokens.ts
45+
46+
- name: Build
47+
run: npm run build -- --configuration production --base-href=/api-explorer/
48+
49+
- name: Detect build output folder
50+
run: |
51+
APP_DIR=$(find dist -mindepth 1 -maxdepth 1 -type d | head -n 1)
52+
53+
if [ -d "$APP_DIR/browser" ]; then
54+
TARGET_DIR="$APP_DIR/browser"
55+
else
56+
TARGET_DIR="$APP_DIR"
57+
fi
58+
59+
echo "TARGET_DIR=$TARGET_DIR" >> "$GITHUB_ENV"
60+
echo "Using build output: $TARGET_DIR"
61+
62+
- name: Copy index.html to 404.html for Angular routing
63+
run: cp "$TARGET_DIR/index.html" "$TARGET_DIR/404.html"
64+
65+
- name: Disable Jekyll
66+
run: touch "$TARGET_DIR/.nojekyll"
67+
68+
- name: Upload Pages artifact
69+
uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: ${{ env.TARGET_DIR }}
72+
73+
deploy:
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.deployment.outputs.page_url }}
77+
runs-on: ubuntu-latest
78+
needs: build
79+
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4

‎.github/workflows/publish-swagger.yml‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎.gitignore‎

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
1-
node_modules
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
22

3-
.env.local
4-
dist/
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
!.vscode/mcp.json
30+
.history/*
31+
32+
# Miscellaneous
33+
/.angular/cache
34+
.sass-cache/
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
testem.log
39+
/typings
40+
__screenshots__/
41+
42+
# System files
43+
.DS_Store
44+
Thumbs.db
45+
46+
# Custom below
47+
.vscode
48+
*.local.ts

‎.prettierrc‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"overrides": [
5+
{
6+
"files": "*.html",
7+
"options": {
8+
"parser": "angular"
9+
}
10+
}
11+
]
12+
}

‎README.md‎

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,38 @@ This repo allows to browse the OpenAPI specs for [opentransportdata.swiss](https
44

55
URL: https://opentdatach.github.io/api-explorer/
66

7-
## Local Preview
7+
## Local Development
88

99
```bash
1010
$ npm install
1111

12-
# generates dist/ from the templates + config
13-
$ npm run build
12+
# duplicate local API credential file
13+
$ cp ./src/app/config/api-tokens.ts ./src/app/config/api-tokens.local.ts
1414

15-
# runs at http://localhost:8080
16-
$ npm run serve
17-
```
18-
19-
## Adds a new API
20-
21-
- get the token (API key) for the new service - https://api-manager.opentransportdata.swiss/
22-
23-
- create a new secret in the repo https://github.com/openTdataCH/api-explorer/settings/secrets/actions
24-
25-
- add the key name as a placeholder the `.env` file and with real value in the `.env.local` file (this is ignored by Git)
26-
```
27-
# .env (commited, in the repo)
28-
API_KEY_NEWAPI=PLACEHOLDER
29-
30-
# .env.local (file excluded from Git)
31-
API_KEY_NEWAPI=eyJvcmciOiI2NDA....
32-
```
15+
# edit api-tokens.local.ts
16+
# fill with tokens obtained from https://api-manager.opentransportdata.swiss/
3317

34-
- add the key to `Build index.html landing page / API folders` task in [.github/workflows/publish-swagger.yml](./.github/workflows/publish-swagger.yml)
18+
# develop on localhost
19+
$ ng serve
3520

21+
# open http://localhost:4200
3622
```
37-
- name: Build index.html landing page / API folders
38-
env:
39-
# from repo secrets https://github.com/openTdataCH/api-explorer/settings/secrets/actions
40-
... more keys
41-
42-
API_KEY_NEWAPI: ${{ secrets.API_KEY_NEWAPI }}
43-
run: |
44-
node scripts/render-openapi.mjs
45-
```
46-
47-
- add a new entry in [apis.yaml](./apis.yaml). the id used will be used in the permalink URL, i.e. for `ojp1.0` the URL + path is https://opentdatach.github.io/api-explorer/ojp1.0/
4823

49-
```
50-
apis:
51-
- id: new_service
52-
title: New Service
53-
map_secrets:
54-
API_KEY: API_KEY_NEWAPI
55-
...
56-
```
57-
58-
- duplicate any of the folders in `openapi/` folder as `openapi/new_service`.
59-
60-
- edit the OpenAPI specs in `openapi/new_service/openapi.template.yaml` file
24+
## Adds a new API
6125

62-
- run `npm build` and inspect the `dist` folder
26+
- get the token (API key) for the new service - https://api-manager.opentransportdata.swiss/
27+
- update config in
28+
- [./src/app/config/api-config.ts](./src/app/config/api-config.ts)
29+
- [./src/app/config/api-tokens.local.ts](./src/app/config/api-tokens.local.ts)
30+
- [./src/app/config/api-tokens.ts](./src/app/config/api-tokens.ts)
31+
- duplicate and edit one of the existing OpenAPI specs - [./public/openapi](./public/openapi)
6332

6433
## Deployment
6534

66-
A GitHub Actions workflow (under [.github/workflows/publish-swagger.yml](./.github/workflows/publish-swagger.yml)) builds the site and publishes it to GitHub Pages on push to the default branch
35+
A GitHub Actions workflow (under [.github/workflows/deploy-pages.yml](./.github/workflows/deploy-pages.yml)) builds the site and publishes it to GitHub Pages on push to the default branch
6736

6837
## License
6938

7039
The project is released under a [MIT license](./LICENSE.txt).
7140

72-
Copyright (c) 2025 Open Data Platform Mobility Switzerland - [opentransportdata.swiss](https://opentransportdata.swiss/en/).
41+
Copyright (c) 2025 - 2026 Open Data Platform Mobility Switzerland - [opentransportdata.swiss](https://opentransportdata.swiss/en/).

0 commit comments

Comments
 (0)