Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ tests/fixture/router.ts
/tests/**/generated-*.yaml

# Ignore coverage reports
lcov.info
lcov.info
coverage
.nyc_output
9 changes: 8 additions & 1 deletion example/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class MyModelTwo extends MyModel {
type!: 'two'
}

/**
* @additionalproperties true
*/
class MyModelThree extends MyModel {
type!: 'three'
}

const securities = { company: [] }

// tslint:disable-next-line: max-classes-per-file
Expand All @@ -58,7 +65,7 @@ export class MyController extends Controller {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@Header('x-foo') foo: string,
@Body('application/json', discriminatorFn) // eslint-disable-next-line @typescript-eslint/no-unused-vars
body: MyModelTwo | MyModel
body: MyModelTwo | MyModel | MyModelThree
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
): {} {
return new MyModelTwo()
Expand Down
17 changes: 2 additions & 15 deletions example/generate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { generate } from '../src'
import path from 'path'
import { inspect } from 'util'
import fs from 'fs'

generate({
tsconfigFilePath: path.resolve(__dirname, './tsconfig.json'),
controllers: [path.resolve(__dirname, './*.ts')],
openapi: {
filePath: '/tmp/openapi.yaml',
filePath: '../tmp/openapi.yaml',
service: {
name: 'my-service',
version: '1.0.0'
Expand All @@ -24,15 +22,4 @@ generate({
filePath: './router.ts',
securityMiddlewarePath: './security.ts'
}
})
.then(() =>
console.log(
inspect(
JSON.parse(fs.readFileSync('/tmp/openapi.yaml').toString()),
false,
100,
true
)
)
)
.catch(err => console.error('error', err))
}).catch(err => console.error('error', err))
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
"build": "tsc --project ./tsconfig.build.json",
"postbuild": "mkdir build/template/ && cp src/template/express.ts.hbs build/template/express.ts.hbs",
"test": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
"testbis": "nyc node --import tsx --experimental-test-coverage --test tests/**/**.test.ts",
"test:coverage": "yarn testbis && nyc report --reporter=html && open coverage/index.html",
"lint": "prettier --write . && eslint --fix ."
},
"engines": {
"node": ">=18.15.0"
},
"dependencies": {
"debug": "4.4.3",
"glob": "13.0.0",
"handlebars": "4.7.8",
"ts-morph": "27.0.2",
"yamljs": "0.3.0"
},
"devDependencies": {
"@types/debug": "4.1.12",
"@types/express": "5.0.6",
Expand All @@ -33,18 +42,13 @@
"eslint-plugin-prettier": "5.5.5",
"eslint-plugin-unicorn": "62.0.0",
"express": "4.17.1",
"nyc": "17.1.0",
"openapi-types": "12.1.3",
"prettier": "3.8.0",
"supertest": "7.2.2",
"tsx": "4.21.0",
"typescript": "5.9.3",
"typescript-eslint": "8.53.0"
},
"dependencies": {
"debug": "4.4.3",
"glob": "13.0.0",
"handlebars": "4.7.8",
"ts-morph": "27.0.2",
"yamljs": "0.3.0"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
Loading