horiuchi / Dtsgenerator
TypeScript d.ts file generate from JSON Schema file
Stars: ✭ 344
Programming Languages
typescript
32286 projects
Labels
Projects that are alternatives of or similar to Dtsgenerator
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+141.57%)
Mutual labels: swagger, json-schema
Raml Server
run a mocked server JUST based on a RAML API's definition .. zero coding
Stars: ✭ 158 (-54.07%)
Mutual labels: swagger, json-schema
Spectral
A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.
Stars: ✭ 876 (+154.65%)
Mutual labels: swagger, json-schema
Spec Tools
Clojure(Script) tools for clojure.spec
Stars: ✭ 524 (+52.33%)
Mutual labels: swagger, json-schema
fhir-fuel.github.io
Place to prepare proposal to FHIR about JSON, JSON-Schema, Swagger/OpenAPI, JSON native databases and other JSON-frendly formats (yaml, edn, avro, protobuf etc) and technologies
Stars: ✭ 20 (-94.19%)
Mutual labels: json-schema, swagger
Full Stack Fastapi Postgresql
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Stars: ✭ 7,635 (+2119.48%)
Mutual labels: swagger, json-schema
Docless
A scala DSL to generate JSON schema and swagger documentation for your web services.
Stars: ✭ 78 (-77.33%)
Mutual labels: swagger, json-schema
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+11408.14%)
Mutual labels: swagger, json-schema
Full Stack Fastapi Couchbase
Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Stars: ✭ 243 (-29.36%)
Mutual labels: swagger, json-schema
Spot
Spot is a concise, developer-friendly way to describe your API contract.
Stars: ✭ 230 (-33.14%)
Mutual labels: swagger, json-schema
Swagger Cli
Swagger 2.0 and OpenAPI 3.0 command-line tool
Stars: ✭ 321 (-6.69%)
Mutual labels: swagger, json-schema
sts
Swagger to sf schema & st column in ng-alain
Stars: ✭ 20 (-94.19%)
Mutual labels: json-schema, swagger
Datamodel Code Generator
Pydantic model generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
Stars: ✭ 393 (+14.24%)
Mutual labels: swagger, json-schema
Swagger Parser
Swagger 2.0 and OpenAPI 3.0 parser/validator
Stars: ✭ 710 (+106.4%)
Mutual labels: swagger, json-schema
Ring Swagger
Swagger Spec for Clojure Web Apps
Stars: ✭ 351 (+2.03%)
Mutual labels: swagger, json-schema
Api Development Tools
📚 A collection of useful resources for building RESTful HTTP+JSON APIs.
Stars: ✭ 2,519 (+632.27%)
Mutual labels: swagger, json-schema
openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (-93.6%)
Mutual labels: json-schema, swagger
json-ref-resolver
[Deprecated] Recursively resolve JSON pointers and remote authorities.
Stars: ✭ 27 (-92.15%)
Mutual labels: json-schema, swagger
dtsgenerator
TypeScript d.ts file generator from JSON Schema file or OpenAPI(Swagger) spec file.
Table of Contents
Install
npm install -g dtsgenerator
Usage
CLI
$ dtsgen --help
Usage: dtsgenerator [options] <file ... | file patterns using node-glob>
Options:
-V, --version output the version number
-c, --config <file> set configuration file path.
--url <url> input json schema from the url. (default: [])
--stdin read stdin with other files or urls.
-o, --out <file> output filename.
-t, --target <version> Specify ECMAScript target version: 'ES3', 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018',
'ES2019', 'ES2020', or 'ESNEXT' (default).
--info for developer mode. output loaded config and plugin details only.
--output-ast output TypeScript AST instead of d.ts file.
-h, --help display help for command
Examples:
$ dtsgen --help
$ dtsgen --out types.d.ts schema/**/*.schema.json
$ cat schema1.json | dtsgen -c dtsgen.json
$ dtsgen -o swaggerSchema.d.ts --url https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json
$ dtsgen -o petstore.d.ts --url https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore.yaml
$ dtsgen -c dtsgen-test.json --info
NodeJS API
const { default: dtsgenerator, parseSchema } = require('dtsgenerator');
dtsgenerator({
contents: [parseSchema({/* JsonSchema object */})],
config: {/* Config object */},
}).then(content => {
/* Do someting with parsed content */
}).catch(err => {
/* Handle errors */
});
Use HTTP/HTTPS Proxy
If you need a proxy to fetch the schema, please set the following environment variables.
export http_proxy=http://proxy.example.com:8080/
export https_proxy=http://proxy.example.com:8080/
# If there are exceptionally hosts that do not go through a proxy
export no_proxy=google.com, yahoo.com
Migration from v2
The dtsgenerator v3 has made the following braking changes from v2.
- Support Plug-in feature. See the Plug-in section for more information.
- Change the command line options.
- Remove the
--namespace
option. Use the@dtsgenerator/replace-namespace
plug-in instead. - Add the
--config
option. Mainly for setting up the Plug-in. - And add more options.
- Remove the
- TypeScript AST is now used internally to generate type definitions.
Plug-in
How to find plug-in
- Search by npm: https://www.npmjs.com/search?q=dtsgenerator%20plugin
- Find by the @dtsgenerator repositories: https://github.com/dtsgenerator
-
@dtsgenerator/replace-namespace
: This plug-in is instead the--namespace
option on old version. -
@dtsgenerator/decorate-typename
: This plug-in can decorate the output type name. -
@dtsgenerator/single-quote
: This plug-in replace the quote mark to single.
-
How to create plug-in
- Scaffold by the command:
npm init @dtsgenerator **plugin-name**
- Edit
**plugin-name**/index.ts
- Do test:
npm test
- Build it:
npm run build
- Publish to npm:
npm publish
Development
Debug
Output debug message by debug library.
$ DEBUG=dtsgen dtsgen schema/news.json
Links about JSON Schema and Swagger
Supported spec and features
-
JSON Schema
- Draft-04 and before
- Draft-07 and before
-
OpenAPI
- OpenAPI Specification version 2.0
- OpenAPI Specification version 3.0
ChangeLog
v3.7.1 (2021-02-18)
- fixed:
- add truthy check for value in
mergeSchema
by #474. Thank you @ricokahler 👍
- add truthy check for value in
v3.7.0 (2021-01-05)
- features:
- Add the
void
type support by #468. Thank you for your propose @henhal by #445 👍
- Add the
v3.6.0 (2020-12-25)
- features:
- Improve the type result of oneOf/anyOf property by #467. Thank you for your report @crizo23 by #452 👍
- Improve the internal eslint configuration by #466. Thank you @Goldziher 👍
v3.5.0 (2020-12-21)
- features:
- Add to export
ts
object for to use the same version TypeScript in all plugins by #465.
- Add to export
v3.4.1 (2020-12-16)
- fixed:
v3.4.0 (2020-12-15)
- features:
v3.3.1 (2020-10-05)
- fixed:
- Elements get type "any" instead of the correct one by #448. Thank you for your report @nachtigall-83 👍
v3.3.0 (2020-07-29)
- features:
- Support the
patternProperties
by #436. Thank you @nfroidure 👍
- Support the
- fixed:
- Definition generated improperly when multiple instances of a resource are inherited by #279. Thank you @btg5679 👍
- Apply the
prettier
config on.eslintrc.json
.
v3.2.0 (2020-07-20)
- features:
- Add support for application/octet-stream media type by #431. Thank you @MisterChateau 👍
v3.1.1 (2020-06-23)
- fixed:
- Cannot load config file of relative path by #428. Thank you @DamianOsipiuk 👍
v3.1.0 (2020-06-22)
- features:
- Add support for nullable anyOf in OpenApi v3 by #426. Thank you @joost-kersjes-webpower 👍
v3.0.3 (2020-06-15)
- fixed:
- Fix the command option example by #422. Thank you @maapteh 👍
- Omit load config error on not config option by #425. Thank you @Christian24 👍
v3.0.2 (2020-06-11)
- fixed:
- Remove old example by #421. Thank you @maapteh 👍
v3.0.1 (2020-06-09)
- features:
- Support the plug-in for pre-process and post-process.
- Change command line options and Support config file.
- Use the TypeScript AST for intermediate format.
older versions history
License
dtsgenerator
is licensed under the MIT license.
Copyright © 2016-2020, Hiroki Horiuchi
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].