Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: glideapps/quicktype
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a1396ea06e585d3f679698e372c8ec9ace7064e4
Choose a base ref
...
head repository: glideapps/quicktype
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e0d304766b1bec2f72271cc295452bae10a1a21a
Choose a head ref
  • 1 commit
  • 371 files changed
  • 1 contributor

Commits on Jan 7, 2023

  1. Prettier (#2071)

    dvdsgl authored Jan 7, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    marsam Mario Rodas
    Copy the full SHA
    e0d3047 View commit details
Showing 371 changed files with 349,088 additions and 154,440 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Build and Release
on:
push:
branches:
- master
push:
branches:
- master

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.12.1
cache: npm
registry-url: "https://registry.npmjs.org"
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.12.1
cache: npm
registry-url: "https://registry.npmjs.org"

- run: npm ci
- run: npm ci

- run: npm run pub
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm run pub
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 8 additions & 10 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
@@ -58,15 +58,15 @@ jobs:
runs-on: [ubuntu-latest]

include:
# Rust is very slow, so we use a larger runner
- fixture: rust,schema-rust
runs-on: ubuntu-latest-8-cores
# Kotlin is also slow
- fixture: kotlin,schema-kotlin,kotlin-jackson,schema-kotlin-jackson
runs-on: ubuntu-latest-8-cores
# Rust is very slow, so we use a larger runner
- fixture: rust,schema-rust
runs-on: ubuntu-latest-8-cores
# Kotlin is also slow
- fixture: kotlin,schema-kotlin,kotlin-jackson,schema-kotlin-jackson
runs-on: ubuntu-latest-8-cores

- fixture: objective-c
runs-on: macos-11
- fixture: objective-c
runs-on: macos-11

name: ${{ matrix.fixture }}
steps:
@@ -78,8 +78,6 @@ jobs:

- run: npm ci



- name: Setup Dart
if: ${{ contains(matrix.fixture, 'dart') }}
uses: dart-lang/setup-dart@v1.3
14 changes: 7 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"esbenp.prettier-vscode",
"eg2.tslint"
]
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"esbenp.prettier-vscode",
"eg2.tslint"
]
}
76 changes: 38 additions & 38 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "quicktype",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"runtimeArgs": ["--nolazy"],
"args": [
"--project",
"src/cli/tsconfig.json",
"src/cli/index.ts",
"--lang",
"dart",
"--src-lang",
"json",
"./test/inputs/json/priority/blns-object.json"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
},
{
"name": "test",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"args": ["--project", "test/tsconfig.json", "test/test.ts"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"env": {
"CPUs": "1",
"FIXTURE": "golang"
}
}
]
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "quicktype",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"runtimeArgs": ["--nolazy"],
"args": [
"--project",
"src/cli/tsconfig.json",
"src/cli/index.ts",
"--lang",
"dart",
"--src-lang",
"json",
"./test/inputs/json/priority/blns-object.json"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
},
{
"name": "test",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/_bin.js",
"args": ["--project", "test/tsconfig.json", "test/test.ts"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"env": {
"CPUs": "1",
"FIXTURE": "golang"
}
}
]
}
43 changes: 20 additions & 23 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
{
// Place your settings in this file to overwrite default and user settings.
"editor.formatOnSave": true,
"spellright.ignoreFiles": [
"**/.gitignore",
"**/.spellignore"
],
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/tmp": true,
"output": true,
"**/obj": true,
"**/bin": true,
"test/inputs": true,
"test/runs": true,
"app/build": true,
"elm-stuff": true,
"dist": true
},
"spellright.documentTypes": [],
"java.configuration.updateBuildConfiguration": "automatic"
}
// Place your settings in this file to overwrite default and user settings.
"editor.formatOnSave": true,
"spellright.ignoreFiles": ["**/.gitignore", "**/.spellignore"],
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/tmp": true,
"output": true,
"**/obj": true,
"**/bin": true,
"test/inputs": true,
"test/runs": true,
"app/build": true,
"elm-stuff": true,
"dist": true
},
"spellright.documentTypes": [],
"java.configuration.updateBuildConfiguration": "automatic"
}
26 changes: 12 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "tslint",
"group": "build",
"problemMatcher": [
"$tslint5"
]
}
]
}
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "tslint",
"group": "build",
"problemMatcher": ["$tslint5"]
}
]
}
22 changes: 11 additions & 11 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
- [Where can I learn more about JSON Schema?](#where-can-i-learn-more-about-json-schema)
- [I'd like to customize the output for my particular application.](#id-like-to-customize-the-output-for-my-particular-application)
- [quicktype is awesome, I'd like to support it!](#quicktype-is-awesome-id-like-to-support-it)
- [How is this different from other JSON converters?](#how-is-quicktype-different-from-other-json-converters)
- [How is this different from other JSON converters?](#how-is-quicktype-different-from-other-json-converters)

## What is this?

@@ -28,16 +28,16 @@ You paste JSON on the left, and code appears on the right. [This video](https://

`quicktype` is superior to other JSON converters in many important ways:

- **Type inference**: quicktype infers optionals, dates, UUIDs, enums, integers, and unions. It also infers maps (versus objects) using a Markov chain.
- **Careful naming**: quicktype’s naming system creates nice, legal, unique names for types and properties, handling reserved words and tricky corner cases (e.g. `{ “”: “this is legal”, “null”: “so is this”, "1;DROP TABLE users”: “and this" }`).
- **Heterogeneous data**: JSON data is often heterogenous. quicktype infers this, and creates union types in languages that support them, or synthetic union types in languages that don’t (e.g. try quicktyping `[0, “zero”]` as Swift and Go).
- **Type unification**. This works across multiple samples, so you can quicktype a directory of API data, for example, and unify types across all responses (e.g. you’ll get just one `Customer` type, even if customer data occurs in many samples). You can also provide multiple samples for the same type for better coverage.
- **Marshalling code**: In addition to types, quicktype generates functions for marshalling your types to and from JSON.
- Supports dynamic languages: quicktype can add dynamic typechecks for JavaScript, TypeScript, Flow, Python, and Ruby.
- **Convenient CLI**: Run `quicktype https://blockchain.info/latestblock -o LatestBlock.ts` to quicktype a Bitcoin API in TypeScript.
- **Client-side**: [The web version of quicktype](https://app.quicktype.io/) runs on the client, so servers never see your data (most JSON converters send your JSON to their server)
- **Typed input**: Feed quicktype TypeScript or JSON Schema instead of JSON for better control over generated types.
- **Code quality**: quicktype emits clean code
- **Type inference**: quicktype infers optionals, dates, UUIDs, enums, integers, and unions. It also infers maps (versus objects) using a Markov chain.
- **Careful naming**: quicktype’s naming system creates nice, legal, unique names for types and properties, handling reserved words and tricky corner cases (e.g. `{ “”: “this is legal”, “null”: “so is this”, "1;DROP TABLE users”: “and this" }`).
- **Heterogeneous data**: JSON data is often heterogenous. quicktype infers this, and creates union types in languages that support them, or synthetic union types in languages that don’t (e.g. try quicktyping `[0, “zero”]` as Swift and Go).
- **Type unification**. This works across multiple samples, so you can quicktype a directory of API data, for example, and unify types across all responses (e.g. you’ll get just one `Customer` type, even if customer data occurs in many samples). You can also provide multiple samples for the same type for better coverage.
- **Marshalling code**: In addition to types, quicktype generates functions for marshalling your types to and from JSON.
- Supports dynamic languages: quicktype can add dynamic typechecks for JavaScript, TypeScript, Flow, Python, and Ruby.
- **Convenient CLI**: Run `quicktype https://blockchain.info/latestblock -o LatestBlock.ts` to quicktype a Bitcoin API in TypeScript.
- **Client-side**: [The web version of quicktype](https://app.quicktype.io/) runs on the client, so servers never see your data (most JSON converters send your JSON to their server)
- **Typed input**: Feed quicktype TypeScript or JSON Schema instead of JSON for better control over generated types.
- **Code quality**: quicktype emits clean code

## How do I use this with my code?

12 changes: 6 additions & 6 deletions PACKAGES.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# The packages

* `quicktype-core`: This is the engine of quicktype. It takes JSON, JSON Schema, and GraphQL input and produces output in a variety of programming languages. We're trying to keep this lean in terms of download size so that it can be embedded, such as in [quicktype-playground](https://github.com/quicktype/quicktype-playground).
- `quicktype-core`: This is the engine of quicktype. It takes JSON, JSON Schema, and GraphQL input and produces output in a variety of programming languages. We're trying to keep this lean in terms of download size so that it can be embedded, such as in [quicktype-playground](https://github.com/quicktype/quicktype-playground).

* `quicktype-typescript-input`: This is a bit of code that allows TypeScript code to be fed as input to `quicktype-core`, by transforming it to JSON Schema with [typescript-json-schema](https://github.com/YousefED/typescript-json-schema). It depends on `quicktype-core`.
- `quicktype-typescript-input`: This is a bit of code that allows TypeScript code to be fed as input to `quicktype-core`, by transforming it to JSON Schema with [typescript-json-schema](https://github.com/YousefED/typescript-json-schema). It depends on `quicktype-core`.

* `quicktype-graphql-input`: This is the GraphQL input module. It's split off into a separate package because it's not used in the web UI and `quicktype-playgrounds`, and it uses the moderately sized `graphql` dependency.
- `quicktype-graphql-input`: This is the GraphQL input module. It's split off into a separate package because it's not used in the web UI and `quicktype-playgrounds`, and it uses the moderately sized `graphql` dependency.

* `quicktype`: This is the command line interface for quicktype. It's a monolithic package that doesn't depend on the other packages, but contains all their code directly. This is mainly for ease of development. Packages that want to use quicktype's CLI interface, such as [json-to-azure-node-schema](https://github.com/json-helpers/json-to-azure-node-schema) will have to use this package.
- `quicktype`: This is the command line interface for quicktype. It's a monolithic package that doesn't depend on the other packages, but contains all their code directly. This is mainly for ease of development. Packages that want to use quicktype's CLI interface, such as [json-to-azure-node-schema](https://github.com/json-helpers/json-to-azure-node-schema) will have to use this package.

# Module resolution

`quicktype-typescript-input` and `quicktype-graphql-input` have to work both as their own packages, depending on the `quicktype-core` package, as well as part of `quicktype`, referring to the files in the local `src/quicktype-core` directory.

In addition, since those two input packages depend on `quicktype-core`, we would have to first build `quicktype-core`, publish it, and then build the input packages, depending on the just published `quicktype-core`. This is bad for development, since we couldn't do modifications to all packages without publishing, if we want to test independent of the `quicktype` package. The same goes for CI. Therefore, the two have to build as packages depending on the local `build/quicktype-core` package, but have to be published depending on the proper `quicktype-core` NPM package. We solve this the following way:

* All packages, including `quicktype-typescript-input` and `quicktype-graphql-input`, import files with local paths, such as `"../quicktype-core"`. This seems the only way to make VSCode's TypeScript integration, as well as `ts-node` happy. Unfortunately, since local paths can's use `tsc`'s path mapping, we have to rewrite those paths _before_ compiling, which is done in `build/quicktype-*-input/build.ts`: it copies all the sources, rewrites them, compiles, and then deletes the copied sources again.
- All packages, including `quicktype-typescript-input` and `quicktype-graphql-input`, import files with local paths, such as `"../quicktype-core"`. This seems the only way to make VSCode's TypeScript integration, as well as `ts-node` happy. Unfortunately, since local paths can's use `tsc`'s path mapping, we have to rewrite those paths _before_ compiling, which is done in `build/quicktype-*-input/build.ts`: it copies all the sources, rewrites them, compiles, and then deletes the copied sources again.

* Depending on whether we build the input packages, or publish them, their `package.json`s will have to refer to either the local `quicktype-core` package, or the NPM one. This is also done by the build script, which replaces the dependency with the right one for the job.
- Depending on whether we build the input packages, or publish them, their `package.json`s will have to refer to either the local `quicktype-core` package, or the NPM one. This is also done by the build script, which replaces the dependency with the right one for the job.

## Issues

47 changes: 47 additions & 0 deletions build/quicktype-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "quicktype-core",
"version": "7.0.0",
"description": "The quicktype engine as a library",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "https://github.com/quicktype/quicktype",
"scripts": {
"clean": "rm -rf dist node_modules *~",
"prepare": "npm run build",
"build": "tsc",
"tslint": "tslint --project ."
},
"dependencies": {
"@mark.probst/unicode-properties": "~1.1.0",
"browser-or-node": "^1.2.1",
"collection-utils": "^1.0.1",
"is-url": "^1.2.4",
"isomorphic-fetch": "^2.2.1",
"js-base64": "^2.4.3",
"pako": "^1.0.6",
"pluralize": "^7.0.0",
"readable-stream": "2.3.0",
"urijs": "^1.19.1",
"wordwrap": "^1.0.0",
"yaml": "^2.2.1"
},
"devDependencies": {
"@types/urijs": "^1.19.8",
"@types/js-base64": "^2.3.1",
"@types/node": "8.10.10",
"@types/pako": "^1.0.0",
"@types/pluralize": "0.0.28",
"@types/yaml": "^1.0.2",
"typescript": "~3.2.1",
"tslint": "^5.11.0",
"@types/readable-stream": "2.3.9",
"@types/browser-or-node": "^1.2.0"
},
"files": [
"dist/**"
],
"browser": {
"fs": false
}
}
Loading