Skip to content

Commit

Permalink
Generate js bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
booxter committed Jul 6, 2024
1 parent 9a43c8d commit 59d64eb
Show file tree
Hide file tree
Showing 43 changed files with 3,714 additions and 29 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/swagger-validate.yml

This file was deleted.

30 changes: 27 additions & 3 deletions .github/workflows/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,34 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.11.x'
- name: Install dependencies
- name: Install nodejs
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Install make
run: |
sudo apt-get update
sudo apt-get install make
- name: Install pdm
run: |
python -m pip install --upgrade pip
pip install .
pip install pdm
- name: Install the package
pdm install
- name: Re-generate swagger.json
run: |
diff -u swagger.json <(swagger)
diff -u swagger.json <(pdm run swagger)
- name: Install openapi-generator-cli
run: |
npm install @openapitools/openapi-generator-cli -g
- name: Validate swagger.json
run: |
openapi-generator-cli validate -i swagger.json
- name: Re-generate client bindings
run: |
make swagger-all
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ repos:
args: [ --fix ]
# Run the formatter.
- id: ruff-format
exclude: 'letsrolld-api-client/.*'
exclude: |
(?x)^(
letsrolld-api-client/.*|
js/.*
)$
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DIRECTORS_FILE?=directors.csv
RUN_LOG?=run.log
RUN_LOG_CMD?=ts | tee -a $(RUN_LOG)

.PHONY: install lint mypy test populate run-update-directors run-update-films run-update-offers run-cleanup run-all run-db-upgrade webapp ui swagger swagger_py get-dirs get-films
.PHONY: install lint mypy test populate run-update-directors run-update-films run-update-offers run-cleanup run-all run-db-upgrade webapp ui swagger swagger-py swagger-js swagger-all get-dirs get-films

install:
pdm install -vd
Expand Down Expand Up @@ -44,12 +44,20 @@ webapp:

swagger:
#curl http://localhost:8000/api/doc/swagger.json -o swagger.json
pdm run swagger > swagger.json
pdm run swagger > swagger.json.tmp
mv swagger.json.tmp swagger.json
openapi-generator-cli validate -i swagger.json

swagger_py: swagger
swagger-py: swagger
rm -rf letsrolld-api-client
pdm run openapi-python-client generate --path swagger.json

swagger-js: swagger
rm -rf js
openapi-generator-cli generate -i swagger.json -g javascript -o js

swagger-all: swagger-py swagger_js

ui:
cd ui && http-server --port 8081 -c-1 -o

Expand Down
33 changes: 33 additions & 0 deletions js/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-optional-chaining",
[
"@babel/plugin-proposal-pipeline-operator",
{
"proposal": "minimal"
}
],
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-function-bind"
]
}
130 changes: 130 additions & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
23 changes: 23 additions & 0 deletions js/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
37 changes: 37 additions & 0 deletions js/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.babelrc
.gitignore
.openapi-generator-ignore
.travis.yml
README.md
docs/ArrayOfDirectors.md
docs/ArrayOfFilms.md
docs/DefaultApi.md
docs/Director.md
docs/DirectorFilmsInner.md
docs/DirectorFilmsInnerCountriesInner.md
docs/DirectorFilmsInnerOffersInner.md
docs/DirectorInfo.md
docs/Film.md
git_push.sh
mocha.opts
package.json
src/ApiClient.js
src/api/DefaultApi.js
src/index.js
src/model/ArrayOfDirectors.js
src/model/ArrayOfFilms.js
src/model/Director.js
src/model/DirectorFilmsInner.js
src/model/DirectorFilmsInnerCountriesInner.js
src/model/DirectorFilmsInnerOffersInner.js
src/model/DirectorInfo.js
src/model/Film.js
test/api/DefaultApi.spec.js
test/model/ArrayOfDirectors.spec.js
test/model/ArrayOfFilms.spec.js
test/model/Director.spec.js
test/model/DirectorFilmsInner.spec.js
test/model/DirectorFilmsInnerCountriesInner.spec.js
test/model/DirectorFilmsInnerOffersInner.spec.js
test/model/DirectorInfo.spec.js
test/model/Film.spec.js
1 change: 1 addition & 0 deletions js/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.1
5 changes: 5 additions & 0 deletions js/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
cache: npm
node_js:
- "6"
- "6.1"
Loading

0 comments on commit 59d64eb

Please sign in to comment.