Add TypeScript as supported input
This commit is contained in:
Родитель
d69ad4ddda
Коммит
40f705e20f
30
README.md
30
README.md
|
@ -12,8 +12,11 @@
|
|||
|
||||
### Supported Inputs
|
||||
|
||||
| JSON | JSON API URLs | [JSON Schema](https://app.quicktype.io/#s=coordinate) | GraphQL queries |
|
||||
| ---- | ------------- | ----------------------------------------------------- | --------------- |
|
||||
| JSON | JSON API URLs | [JSON Schema](https://app.quicktype.io/#s=coordinate) |
|
||||
| ---- | ------------- | ----------------------------------------------------- |
|
||||
|
||||
| TypeScript | GraphQL queries |
|
||||
| ---------- | --------------- |
|
||||
|
||||
|
||||
### Target Languages
|
||||
|
@ -80,6 +83,8 @@ quicktype ./blockchain -o blockchain-api.cpp
|
|||
quicktype https://api.somewhere.com/data -o Data.java
|
||||
```
|
||||
|
||||
### Generating code from JSON schema
|
||||
|
||||
The recommended way to use `quicktype` is to generate a JSON schema from sample data, review and edit the schema, commit the schema to your project repo, then generate code from the schema as part of your build process:
|
||||
|
||||
```bash
|
||||
|
@ -100,6 +105,27 @@ quicktype -s schema schema.json -o src/nodejs/Models.ts
|
|||
# seamlessly.
|
||||
```
|
||||
|
||||
### Generating code from TypeScript (Experimental)
|
||||
|
||||
You can achieve a similar result by writing or generating a [TypeScript](http://www.typescriptlang.org/) file, then quicktyping it. TypeScript is a typed superset of JavaScript with simple, succint syntax for defining types:
|
||||
|
||||
```typescript
|
||||
interface Person {
|
||||
name: string;
|
||||
nickname?: string; // an optional property
|
||||
luckyNumber: number;
|
||||
}
|
||||
```
|
||||
|
||||
You can use TypeScript just like JSON schema was used in the last example:
|
||||
|
||||
```bash
|
||||
# First, infer a TypeScript file from a sample (or just write one!)
|
||||
quicktype pokedex.json -o pokedex.ts --just-types
|
||||
# Review the TypeScript, make changes, etc.
|
||||
quicktype pokedex.ts -o src/ios/models.swift
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
`quicktype` is [Open Source](LICENSE) and we love contributors! In fact, we have a [list of issues](https://github.com/quicktype/quicktype/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3Ahelp-wanted) that are low-priority for us, but for which we'd happily accept contributions. Support for new target languages is also strongly desired. If you'd like to contribute, need help with anything at all, or would just like to talk things over, come [join us on Slack](http://slack.quicktype.io).
|
||||
|
|
Загрузка…
Ссылка в новой задаче