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

wip: Manual api generation #2

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/
node_modules/
yarn-error.log
src/generated/
/scratch
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# NMOS + TypeScript = 🚀

* yarn
* yarn submodules
- yarn
- yarn submodules

## Tools
* Update bun `curl -fsSL https://bun.sh/install | bash`.
* yarn tool:generate

- yarn tool:generate

### Why is there a custom generator?

In late 2023 when starting to work on this generator, there were not any maintained options for translating the api from RAML into Typescript.
Even trying to convert the numerous json schemas into typescript resulted in quite a mess of duplicated types and name collisions.

If AMWA translate the types into openapi in the future, or use that for future versions of the specs then hopefully this can be revisited in the future.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"main": "./build/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf build && tsc",
"build": "yarn tool:generate && rimraf build && tsc",
"dev": "DEBUG_WRITE_TO_FILE=1 nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/main.ts",
"submodules": "git submodule init && git submodule update",
"release": "release-it",
"tool:generate": "bun ./tools/generate.ts"
"tool:generate": "node --loader ts-node/esm ./tools/generate.mts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,18 +41,19 @@
"homepage": "https://github.com/bitfocus/nmos#readme",
"devDependencies": {
"@tsconfig/node18": "^18.2.2",
"@types/js-yaml": "^4.0.9",
"@types/node": "^18.18.14",
"change-case": "^5.2.0",
"js-yaml": "^4.1.0",
"json-schema-to-typescript": "^13.1.1",
"nodemon": "^3.0.1",
"prettier": "^3.1.0",
"release-it": "15",
"rimraf": "^5.0.5",
"ts-node": "^10.9.1",
"typescript": "~5.2"
},
"dependencies": {
"chalk": "^5.3.0",
"raml2obj": "^6.8.1",
"yaml": "^2.3.4"
"dependencies": {},
"engines": {
"node": ">=18.18"
}
}
Loading