├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── master.yaml │ ├── setup │ └── action.yaml │ └── test-pr.yaml ├── .gitignore ├── .nvmrc ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── FAQ.md ├── LICENSE ├── README.md ├── biome.json ├── data └── lib.d.ts ├── doc ├── CustomRenderer.md ├── PostmanCollection.schema ├── Templates.md └── Transformers.md ├── media ├── faq │ ├── disable-detect-maps.png │ └── options-panel.png └── quicktype-logo.svg ├── package-lock.json ├── package.json ├── packages ├── quicktype-core │ ├── env.sh │ ├── package.json │ ├── src │ │ ├── Annotation.ts │ │ ├── ConvenienceRenderer.ts │ │ ├── CycleBreaker.ts │ │ ├── DateTime.ts │ │ ├── DeclarationIR.ts │ │ ├── EncodedMarkovChain.ts │ │ ├── GatherNames.ts │ │ ├── Graph.ts │ │ ├── GraphRewriting.ts │ │ ├── Inference.ts │ │ ├── MakeTransformations.ts │ │ ├── MarkovChain.ts │ │ ├── Messages.ts │ │ ├── Naming.ts │ │ ├── Renderer.ts │ │ ├── RendererOptions │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── Run.ts │ │ ├── Source.ts │ │ ├── TargetLanguage.ts │ │ ├── Transformers.ts │ │ ├── Type │ │ │ ├── ProvenanceTypeAttributeKind.ts │ │ │ ├── TransformedStringType.ts │ │ │ ├── Type.ts │ │ │ ├── TypeBuilder.ts │ │ │ ├── TypeBuilderUtils.ts │ │ │ ├── TypeGraph.ts │ │ │ ├── TypeGraphUtils.ts │ │ │ ├── TypeRef.ts │ │ │ ├── TypeUtils.ts │ │ │ └── index.ts │ │ ├── UnifyClasses.ts │ │ ├── UnionBuilder.ts │ │ ├── attributes │ │ │ ├── AccessorNames.ts │ │ │ ├── Constraints.ts │ │ │ ├── Description.ts │ │ │ ├── EnumValues.ts │ │ │ ├── StringTypes.ts │ │ │ ├── TypeAttributes.ts │ │ │ ├── TypeNames.ts │ │ │ └── URIAttributes.ts │ │ ├── index.ts │ │ ├── input │ │ │ ├── CompressedJSON.ts │ │ │ ├── FetchingJSONSchemaStore.ts │ │ │ ├── Inference.ts │ │ │ ├── Inputs.ts │ │ │ ├── JSONSchemaInput.ts │ │ │ ├── JSONSchemaStore.ts │ │ │ ├── PathElement.ts │ │ │ ├── PostmanCollection.ts │ │ │ └── io │ │ │ │ ├── $fetch.ci.ts │ │ │ │ ├── $fetch.ts │ │ │ │ ├── NodeIO.ts │ │ │ │ └── get-stream │ │ │ │ ├── buffer-stream.ts │ │ │ │ ├── index.ts │ │ │ │ └── license │ │ ├── language │ │ │ ├── All.ts │ │ │ ├── CJSON │ │ │ │ ├── CJSONRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── CPlusPlus │ │ │ │ ├── CPlusPlusRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── CSharp │ │ │ │ ├── CSharpRenderer.ts │ │ │ │ ├── NewtonSoftCSharpRenderer.ts │ │ │ │ ├── SystemTextJsonCSharpRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Crystal │ │ │ │ ├── CrystalRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Dart │ │ │ │ ├── DartRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Elixir │ │ │ │ ├── ElixirRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Elm │ │ │ │ ├── ElmRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Golang │ │ │ │ ├── GolangRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Haskell │ │ │ │ ├── HaskellRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── JSONSchema │ │ │ │ ├── JSONSchemaRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Java │ │ │ │ ├── DateTimeProvider.ts │ │ │ │ ├── JavaJacksonRenderer.ts │ │ │ │ ├── JavaRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── JavaScript │ │ │ │ ├── JavaScriptRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ ├── unicodeMaps.ts │ │ │ │ └── utils.ts │ │ │ ├── JavaScriptPropTypes │ │ │ │ ├── JavaScriptPropTypesRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ └── language.ts │ │ │ ├── Kotlin │ │ │ │ ├── KotlinJacksonRenderer.ts │ │ │ │ ├── KotlinKlaxonRenderer.ts │ │ │ │ ├── KotlinRenderer.ts │ │ │ │ ├── KotlinXRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Objective-C │ │ │ │ ├── ObjectiveCRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Php │ │ │ │ ├── PhpRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Pike │ │ │ │ ├── PikeRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Python │ │ │ │ ├── JSONPythonRenderer.ts │ │ │ │ ├── PythonRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Ruby │ │ │ │ ├── RubyRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Rust │ │ │ │ ├── RustRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Scala3 │ │ │ │ ├── CirceRenderer.ts │ │ │ │ ├── Scala3Renderer.ts │ │ │ │ ├── UpickleRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Smithy4s │ │ │ │ ├── Smithy4sRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── Swift │ │ │ │ ├── SwiftRenderer.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── TypeScriptEffectSchema │ │ │ │ ├── TypeScriptEffectSchemaRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ └── language.ts │ │ │ ├── TypeScriptFlow │ │ │ │ ├── FlowRenderer.ts │ │ │ │ ├── TypeScriptFlowBaseRenderer.ts │ │ │ │ ├── TypeScriptRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── language.ts │ │ │ │ └── utils.ts │ │ │ ├── TypeScriptZod │ │ │ │ ├── TypeScriptZodRenderer.ts │ │ │ │ ├── index.ts │ │ │ │ └── language.ts │ │ │ ├── index.ts │ │ │ ├── options.types.ts │ │ │ └── types.ts │ │ ├── rewrites │ │ │ ├── CombineClasses.ts │ │ │ ├── ExpandStrings.ts │ │ │ ├── FlattenStrings.ts │ │ │ ├── FlattenUnions.ts │ │ │ ├── InferMaps.ts │ │ │ ├── ReplaceObjectType.ts │ │ │ └── ResolveIntersections.ts │ │ ├── support │ │ │ ├── Acronyms.const.ts │ │ │ ├── Acronyms.ts │ │ │ ├── Chance.ts │ │ │ ├── Comments.ts │ │ │ ├── Converters.ts │ │ │ ├── Strings.ts │ │ │ └── Support.ts │ │ └── types.ts │ └── tsconfig.json ├── quicktype-graphql-input │ ├── package.json │ ├── src │ │ ├── GraphQLSchema.ts │ │ └── index.ts │ └── tsconfig.json ├── quicktype-typescript-input │ ├── package.json │ ├── src │ │ ├── EncodedDefaultTypeScriptLibrary.ts │ │ └── index.ts │ └── tsconfig.json └── quicktype-vscode │ ├── .gitignore │ ├── .vscodeignore │ ├── LICENSE │ ├── README.md │ ├── media │ ├── demo-interactive.gif │ ├── demo.gif │ └── icon.png │ ├── package.json │ ├── quicktype-23.0.122.vsix │ ├── src │ └── extension.ts │ └── tsconfig.json ├── script ├── dev ├── dev.ps1 ├── homebrew-update.sh ├── make-encoded-markov-chain.sh ├── make-encoded-ts-lib.sh ├── patch-npm-version.ts ├── publish.sh ├── quickesttype ├── quicktype ├── test └── watch ├── src ├── CompressedJSONFromStream.ts ├── GraphQLIntrospection.ts ├── TypeSource.ts ├── URLGrammar.ts └── index.ts ├── test ├── .gitignore ├── acronyms.txt ├── awesome-json-datasets ├── buildkite.ts ├── compare-all.sh ├── fixtures.ts ├── fixtures │ ├── cjson │ │ └── main.c │ ├── cplusplus │ │ ├── Generators.hpp │ │ └── main.cpp │ ├── crystal │ │ └── main.cr │ ├── csharp-SystemTextJson │ │ ├── .gitignore │ │ ├── .vscode │ │ │ ├── launch.json │ │ │ └── tasks.json │ │ ├── Program.cs │ │ └── test.csproj │ ├── csharp │ │ ├── .gitignore │ │ ├── .vscode │ │ │ ├── launch.json │ │ │ └── tasks.json │ │ ├── Program.cs │ │ └── test.csproj │ ├── dart │ │ └── parser.dart │ ├── elixir │ │ ├── .gitignore │ │ ├── main.exs │ │ ├── mix.exs │ │ └── mix.lock │ ├── elm │ │ ├── .gitignore │ │ ├── Main.elm │ │ ├── elm-package.json │ │ └── runner.js │ ├── flow │ │ ├── .flowconfig │ │ └── main.js │ ├── golang │ │ └── main.go │ ├── haskell │ │ ├── .gitignore │ │ ├── Main.hs │ │ ├── QuickType.hs │ │ ├── Setup.hs │ │ ├── package.yaml │ │ ├── stack.yaml │ │ └── stack.yaml.lock │ ├── java-lombok │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ ├── org.eclipse.jdt.core.prefs │ │ │ └── org.eclipse.m2e.core.prefs │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── io │ │ │ └── quicktype │ │ │ ├── App.java │ │ │ ├── Converter.java │ │ │ └── TopLevel.java │ ├── java │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ ├── org.eclipse.jdt.core.prefs │ │ │ └── org.eclipse.m2e.core.prefs │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── io │ │ │ └── quicktype │ │ │ ├── App.java │ │ │ ├── Converter.java │ │ │ └── TopLevel.java │ ├── javascript-prop-types │ │ ├── main.js │ │ ├── package-lock.json │ │ └── package.json │ ├── javascript │ │ └── main.js │ ├── kotlin-jackson │ │ ├── .gitignore │ │ ├── build.sh │ │ ├── jackson-annotations-2.9.0.jar │ │ ├── jackson-core-2.9.7.jar │ │ ├── jackson-databind-2.9.7.jar │ │ ├── jackson-module-kotlin-2.9.7.jar │ │ ├── main.kt │ │ ├── run.sh │ │ └── runfixture.sh │ ├── kotlin │ │ ├── .gitignore │ │ ├── TopLevel.kt │ │ ├── build.sh │ │ ├── klaxon-3.0.1.jar │ │ ├── main.kt │ │ ├── run.sh │ │ └── sample.json │ ├── objective-c │ │ ├── ObjectiveCFixture.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcuserdata │ │ │ │ └── david.xcuserdatad │ │ │ │ └── xcschemes │ │ │ │ ├── ObjectiveCFixture.xcscheme │ │ │ │ └── xcschememanagement.plist │ │ ├── QTTopLevel.h │ │ ├── QTTopLevel.m │ │ ├── main.m │ │ └── sample.json │ ├── php │ │ └── main.php │ ├── pike │ │ └── main.pike │ ├── python │ │ ├── main.py │ │ └── run.sh │ ├── ruby │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ └── main.rb │ ├── rust │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── main.rs │ ├── scala3 │ │ ├── .gitignore │ │ ├── circe.scala │ │ ├── rename │ │ │ ├── debug.scala │ │ │ └── upickle.scala │ │ └── run.sh │ ├── swift │ │ ├── .gitignore │ │ ├── SwiftFixture.xcodeproj │ │ │ └── project.pbxproj │ │ ├── main.swift │ │ └── quicktype.swift │ ├── typescript-effect-schema │ │ ├── main.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ ├── typescript-zod │ │ ├── main.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ └── typescript │ │ ├── main.ts │ │ └── tsconfig.json ├── generate-json.py ├── generate-markov-corpus.py ├── inputs │ ├── graphql │ │ ├── github.gqlschema │ │ ├── github1.1.json │ │ ├── github1.graphql │ │ ├── github2.1.json │ │ ├── github2.graphql │ │ ├── github3.1.json │ │ ├── github3.graphql │ │ ├── github4.1.json │ │ ├── github4.graphql │ │ ├── github5.1.json │ │ ├── github5.2.json │ │ ├── github5.graphql │ │ ├── github6.1.json │ │ ├── github6.graphql │ │ ├── github7.1.json │ │ ├── github7.graphql │ │ ├── github8.1.json │ │ ├── github8.graphql │ │ ├── github9.1.json │ │ └── github9.graphql │ ├── json │ │ ├── misc │ │ │ ├── 00c36.json │ │ │ ├── 00ec5.json │ │ │ ├── 010b1.json │ │ │ ├── 016af.json │ │ │ ├── 033b1.json │ │ │ ├── 050b0.json │ │ │ ├── 06bee.json │ │ │ ├── 07540.json │ │ │ ├── 0779f.json │ │ │ ├── 07c75.json │ │ │ ├── 09f54.json │ │ │ ├── 0a358.json │ │ │ ├── 0a91a.json │ │ │ ├── 0b91a.json │ │ │ ├── 0cffa.json │ │ │ ├── 0e0c2.json │ │ │ ├── 0fecf.json │ │ │ ├── 10be4.json │ │ │ ├── 112b5.json │ │ │ ├── 127a1.json │ │ │ ├── 13d8d.json │ │ │ ├── 14d38.json │ │ │ ├── 167d6.json │ │ │ ├── 16bc5.json │ │ │ ├── 176f1.json │ │ │ ├── 1a7f5.json │ │ │ ├── 1b28c.json │ │ │ ├── 1b409.json │ │ │ ├── 2465e.json │ │ │ ├── 24f52.json │ │ │ ├── 262f0.json │ │ │ ├── 26b49.json │ │ │ ├── 26c9c.json │ │ │ ├── 27332.json │ │ │ ├── 29f47.json │ │ │ ├── 2d4e2.json │ │ │ ├── 2df80.json │ │ │ ├── 31189.json │ │ │ ├── 32431.json │ │ │ ├── 32d5c.json │ │ │ ├── 337ed.json │ │ │ ├── 33d2e.json │ │ │ ├── 34702.json │ │ │ ├── 3536b.json │ │ │ ├── 3659d.json │ │ │ ├── 36d5d.json │ │ │ ├── 3a6b3.json │ │ │ ├── 3e9a3.json │ │ │ ├── 3f1ce.json │ │ │ ├── 421d4.json │ │ │ ├── 437e7.json │ │ │ ├── 43970.json │ │ │ ├── 43eaf.json │ │ │ ├── 458db.json │ │ │ ├── 4961a.json │ │ │ ├── 4a0d7.json │ │ │ ├── 4a455.json │ │ │ ├── 4c547.json │ │ │ ├── 4d6fb.json │ │ │ ├── 4e336.json │ │ │ ├── 54147.json │ │ │ ├── 54d32.json │ │ │ ├── 570ec.json │ │ │ ├── 5dd0d.json │ │ │ ├── 5eae5.json │ │ │ ├── 5eb20.json │ │ │ ├── 5f3a1.json │ │ │ ├── 5f7fe.json │ │ │ ├── 617e8.json │ │ │ ├── 61b66.json │ │ │ ├── 6260a.json │ │ │ ├── 65dec.json │ │ │ ├── 66121.json │ │ │ ├── 6617c.json │ │ │ ├── 67c03.json │ │ │ ├── 68c30.json │ │ │ ├── 6c155.json │ │ │ ├── 6de06.json │ │ │ ├── 6dec6.json │ │ │ ├── 6eb00.json │ │ │ ├── 70c77.json │ │ │ ├── 734ad.json │ │ │ ├── 75912.json │ │ │ ├── 7681c.json │ │ │ ├── 76ae1.json │ │ │ ├── 77392.json │ │ │ ├── 7d397.json │ │ │ ├── 7d722.json │ │ │ ├── 7df41.json │ │ │ ├── 7dfa6.json │ │ │ ├── 7eb30.json │ │ │ ├── 7f568.json │ │ │ ├── 7fbfb.json │ │ │ ├── 80aff.json │ │ │ ├── 82509.json │ │ │ ├── 8592b.json │ │ │ ├── 88130.json │ │ │ ├── 8a62c.json │ │ │ ├── 908db.json │ │ │ ├── 9617f.json │ │ │ ├── 96f7c.json │ │ │ ├── 9847b.json │ │ │ ├── 9929c.json │ │ │ ├── 996bd.json │ │ │ ├── 9a503.json │ │ │ ├── 9ac3b.json │ │ │ ├── 9eed5.json │ │ │ ├── a0496.json │ │ │ ├── a1eca.json │ │ │ ├── a3d8c.json │ │ │ ├── a45b0.json │ │ │ ├── a71df.json │ │ │ ├── a9691.json │ │ │ ├── ab0d1.json │ │ │ ├── abb4b.json │ │ │ ├── ac944.json │ │ │ ├── ad8be.json │ │ │ ├── ae7f0.json │ │ │ ├── ae9ca.json │ │ │ ├── af2d1.json │ │ │ ├── b4865.json │ │ │ ├── b6f2c.json │ │ │ ├── b6fe5.json │ │ │ ├── b9f64.json │ │ │ ├── bb1ec.json │ │ │ ├── be234.json │ │ │ ├── c0356.json │ │ │ ├── c0a3a.json │ │ │ ├── c3303.json │ │ │ ├── c6cfd.json │ │ │ ├── c8c7e.json │ │ │ ├── cb0cc.json │ │ │ ├── cb81e.json │ │ │ ├── ccd18.json │ │ │ ├── cd238.json │ │ │ ├── cd463.json │ │ │ ├── cda6c.json │ │ │ ├── cf0d8.json │ │ │ ├── cfbce.json │ │ │ ├── d0908.json │ │ │ ├── d23d5.json │ │ │ ├── dbfb3.json │ │ │ ├── dc44f.json │ │ │ ├── dd1ce.json │ │ │ ├── dec3a.json │ │ │ ├── df957.json │ │ │ ├── e0ac7.json │ │ │ ├── e2915.json │ │ │ ├── e2a58.json │ │ │ ├── e324e.json │ │ │ ├── e53b5.json │ │ │ ├── e64a0.json │ │ │ ├── e8a0b.json │ │ │ ├── e8b04.json │ │ │ ├── ed095.json │ │ │ ├── f22f5.json │ │ │ ├── f3139.json │ │ │ ├── f3edf.json │ │ │ ├── f466a.json │ │ │ ├── f6a65.json │ │ │ ├── f74d5.json │ │ │ ├── f82d9.json │ │ │ ├── f974d.json │ │ │ ├── faff5.json │ │ │ ├── fcca3.json │ │ │ └── fd329.json │ │ ├── priority │ │ │ ├── blns-object.json │ │ │ ├── bug427.json │ │ │ ├── bug790.json │ │ │ ├── bug855-short.json │ │ │ ├── bug863.json │ │ │ ├── coin-pairs.json │ │ │ ├── combinations1.json │ │ │ ├── combinations2.json │ │ │ ├── combinations3.json │ │ │ ├── combinations4.json │ │ │ ├── combined-enum.json │ │ │ ├── direct-recursive.json │ │ │ ├── empty-enum.json │ │ │ ├── identifiers.json │ │ │ ├── keywords.json │ │ │ ├── list.json │ │ │ ├── name-style.json │ │ │ ├── nbl-stats.json │ │ │ ├── no-classes.json │ │ │ ├── nst-test-suite.json │ │ │ ├── number-map.json │ │ │ ├── optional-union.json │ │ │ ├── recursive.json │ │ │ ├── simple-identifiers.json │ │ │ ├── union-constructor-clash.json │ │ │ ├── unions.json │ │ │ └── url.json │ │ └── samples │ │ │ ├── bitcoin-block.json │ │ │ ├── getting-started.json │ │ │ ├── github-events.json │ │ │ ├── kitchen-sink.json │ │ │ ├── null-safe.json │ │ │ ├── pokedex.json │ │ │ ├── reddit.json │ │ │ ├── simple-object.json │ │ │ ├── spotify-album.json │ │ │ ├── us-avg-temperatures.json │ │ │ └── us-senators.json │ ├── schema │ │ ├── a │ │ │ └── test2.json │ │ ├── accessors.1.json │ │ ├── accessors.schema │ │ ├── any.1.json │ │ ├── any.2.json │ │ ├── any.3.json │ │ ├── any.schema │ │ ├── b │ │ │ └── test3.json │ │ ├── bool-string.1.fail.bool-string.json │ │ ├── bool-string.1.json │ │ ├── bool-string.1.out.bool-string.json │ │ ├── bool-string.2.json │ │ ├── bool-string.3.json │ │ ├── bool-string.schema │ │ ├── camelCase.schema │ │ ├── camelCase1.json │ │ ├── class-map-union.1.fail.union.json │ │ ├── class-map-union.1.json │ │ ├── class-map-union.2.json │ │ ├── class-map-union.3.json │ │ ├── class-map-union.4.json │ │ ├── class-map-union.schema │ │ ├── class-with-additional.1.fail.union.json │ │ ├── class-with-additional.1.json │ │ ├── class-with-additional.schema │ │ ├── constructor.1.json │ │ ├── constructor.schema │ │ ├── cut-enum.1.json │ │ ├── cut-enum.schema │ │ ├── date-time-or-string.schema │ │ ├── date-time.1.fail.date-time.json │ │ ├── date-time.1.json │ │ ├── date-time.schema │ │ ├── description-with-double-quotes.json │ │ ├── description-with-double-quotes.schema │ │ ├── description.1.json │ │ ├── description.2.json │ │ ├── description.schema │ │ ├── direct-union.1.json │ │ ├── direct-union.schema │ │ ├── enum-with-null.1.json │ │ ├── enum-with-null.2.json │ │ ├── enum-with-null.schema │ │ ├── enum-with-values.schema │ │ ├── enum.1.fail.enum.json │ │ ├── enum.1.json │ │ ├── enum.2.json │ │ ├── enum.3.json │ │ ├── enum.4.json │ │ ├── enum.schema │ │ ├── go-schema-pattern-properties.1.fail.json │ │ ├── go-schema-pattern-properties.1.json │ │ ├── go-schema-pattern-properties.schema │ │ ├── id-no-address.1.json │ │ ├── id-no-address.schema │ │ ├── id-root.1.json │ │ ├── id-root.schema │ │ ├── implicit-all-of.1.json │ │ ├── implicit-all-of.schema │ │ ├── implicit-class-array-union.1.fail.union.json │ │ ├── implicit-class-array-union.1.json │ │ ├── implicit-class-array-union.2.fail.union.json │ │ ├── implicit-class-array-union.2.json │ │ ├── implicit-class-array-union.3.json │ │ ├── implicit-class-array-union.4.json │ │ ├── implicit-class-array-union.5.json │ │ ├── implicit-class-array-union.schema │ │ ├── implicit-one-of.1.json │ │ ├── implicit-one-of.2.json │ │ ├── implicit-one-of.schema │ │ ├── integer-float-union.1.json │ │ ├── integer-float-union.2.json │ │ ├── integer-float-union.schema │ │ ├── integer-string.1.fail.integer-string.json │ │ ├── integer-string.1.json │ │ ├── integer-string.1.out.integer-string.json │ │ ├── integer-string.2.json │ │ ├── integer-string.3.json │ │ ├── integer-string.schema │ │ ├── intersection-nested.schema │ │ ├── intersection.1.fail.no-defaults.json │ │ ├── intersection.1.json │ │ ├── intersection.2.json │ │ ├── intersection.schema │ │ ├── keyword-enum.1.json │ │ ├── keyword-enum.schema │ │ ├── keyword-unions.1.json │ │ ├── keyword-unions.2.json │ │ ├── keyword-unions.schema │ │ ├── list.1.json │ │ ├── list.2.json │ │ ├── list.3.json │ │ ├── list.schema │ │ ├── minmax-integer.1.fail.minmaxInteger.json │ │ ├── minmax-integer.1.json │ │ ├── minmax-integer.schema │ │ ├── minmax.1.fail.minmax.json │ │ ├── minmax.1.json │ │ ├── minmax.schema │ │ ├── minmaxlength.1.fail.minmaxlength.json │ │ ├── minmaxlength.1.json │ │ ├── minmaxlength.schema │ │ ├── multi-type-enum.1.fail.union.json │ │ ├── multi-type-enum.1.json │ │ ├── multi-type-enum.2.json │ │ ├── multi-type-enum.3.json │ │ ├── multi-type-enum.schema │ │ ├── mutually-recursive.1.json │ │ ├── mutually-recursive.2.json │ │ ├── mutually-recursive.schema │ │ ├── non-standard-ref.1.json │ │ ├── non-standard-ref.schema │ │ ├── object-type-required.1.json │ │ ├── object-type-required.2.json │ │ ├── object-type-required.schema │ │ ├── optional-any.1.json │ │ ├── optional-any.2.json │ │ ├── optional-any.schema │ │ ├── pattern.1.fail.pattern.json │ │ ├── pattern.1.json │ │ ├── pattern.schema │ │ ├── postman-collection.1.json │ │ ├── postman-collection.2.json │ │ ├── postman-collection.schema │ │ ├── ref-id-files.1.json │ │ ├── ref-id-files.schema │ │ ├── ref-remote.1.json │ │ ├── ref-remote.2.json │ │ ├── ref-remote.3.json │ │ ├── ref-remote.schema │ │ ├── renaming-bug.schema │ │ ├── required-draft3.schema │ │ ├── required-non-properties.1.json │ │ ├── required-non-properties.schema │ │ ├── required.1.fail.no-defaults.json │ │ ├── required.schema │ │ ├── simple-ref.1.json │ │ ├── simple-ref.1.ref │ │ ├── simple-ref.2.json │ │ ├── simple-ref.3.json │ │ ├── simple-ref.schema │ │ ├── strict-optional.1.fail.strict-optional.json │ │ ├── strict-optional.schema │ │ ├── top-level-enum.1.json │ │ ├── top-level-enum.schema │ │ ├── top-level-primitive.schema │ │ ├── tuple.1.json │ │ ├── tuple.schema │ │ ├── union-list.1.json │ │ ├── union-list.2.json │ │ ├── union-list.3.json │ │ ├── union-list.schema │ │ ├── union.1.json │ │ ├── union.schema │ │ ├── uuid.1.fail.uuid.json │ │ ├── uuid.1.json │ │ ├── uuid.2.json │ │ ├── uuid.schema │ │ └── vega-lite.schema │ ├── spotify-api │ │ ├── Album │ │ │ ├── She's So Unusual.json │ │ │ └── The Best of Keane (Deluxe Edition).json │ │ ├── Artist.json │ │ ├── Playlist.json │ │ ├── Track.json │ │ └── UserProfile.json │ └── urls │ │ └── github.json ├── keywords.py ├── keywords.txt ├── languages.ts ├── lib │ ├── deepEquals.ts │ └── multicore.ts ├── make-keyword-tests.sh ├── run-for-all.sh ├── test-awesome.py ├── test.ts ├── tsconfig.json └── utils.ts └── tsconfig.json /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | scripts/* eol=lf 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: quicktype 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | # contact_links: 3 | # - name: GitHub Community Support 4 | # url: https://github.com/orgs/community/discussions 5 | # about: Please ask and answer questions here. 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Use this template for requesting new features. 4 | title: "[FEATURE]: feature description here" 5 | labels: enhancement 6 | --- 7 | 8 | 9 | 10 | ## Context (Input, Language) 11 | 12 | 13 | 14 | Input Format: 15 | Output Language: 16 | 17 | ## Description 18 | 19 | 20 | 21 | 22 | ## Current Behaviour / Output 23 | 24 | 25 | 26 | ## Proposed Behaviour / Output 27 | 28 | 29 | 30 | ## Solution 31 | 32 | 33 | 34 | ## Alternatives 35 | 36 | 37 | 38 | ## Context 39 | 40 | 41 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | 5 | ## Related Issue 6 | 7 | 8 | 9 | 10 | 11 | ## Motivation and Context 12 | 13 | 14 | 15 | 16 | ## Previous Behaviour / Output 17 | 18 | 19 | 20 | ## New Behaviour / Output 21 | 22 | 23 | 24 | ## How Has This Been Tested? 25 | 26 | 27 | 28 | 29 | ## Screenshots (if appropriate): 30 | -------------------------------------------------------------------------------- /.github/workflows/master.yaml: -------------------------------------------------------------------------------- 1 | name: Build and Release 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: ./.github/workflows/setup 13 | env: 14 | PUBLISH: true 15 | - run: npm run pub 16 | env: 17 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 18 | VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }} 19 | -------------------------------------------------------------------------------- /.github/workflows/setup/action.yaml: -------------------------------------------------------------------------------- 1 | name: Setup 2 | description: Setup common stuff for jobs 3 | runs: 4 | using: "composite" 5 | steps: 6 | - name: Setup environment 7 | shell: bash 8 | run: | 9 | NODE_VERSION=$(cat .nvmrc | xargs) 10 | echo "node_version=$NODE_VERSION" >> $GITHUB_ENV 11 | 12 | # Create keys to control caching 13 | BASE_KEY="${{ runner.os }}" 14 | 15 | NODE_MODULES_KEY="$BASE_KEY-${{ hashFiles('package-lock.json') }}" 16 | echo "node_modules_key=$NODE_MODULES_KEY" >> $GITHUB_ENV 17 | 18 | SOURCE_KEY="$NODE_MODULES_KEY-${{ hashFiles('src/**') }}" 19 | echo "source_key=$SOURCE_KEY" >> $GITHUB_ENV 20 | 21 | - name: Setup node 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ env.node_version }} 25 | cache: npm 26 | registry-url: "https://registry.npmjs.org" 27 | 28 | - name: Install Dependencies 29 | run: npm ci 30 | shell: bash 31 | 32 | - name: Build Packages 33 | run: npm run build 34 | shell: bash 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | /test/awesome-json-results/ 3 | npm-debug.log 4 | yarn.lock 5 | shrinkwrap.yaml 6 | test/csharp/QuickType.cs 7 | test/golang/quicktype.go 8 | test/golang/schema.json 9 | test/golang/schema-from-schema.json 10 | test/elm/elm-stuff/ 11 | test/elm/elm.js 12 | test/elm/QuickType.elm 13 | test/fixtures/cjson/cJSON.* 14 | test/fixtures/cjson/hashtable.* 15 | test/fixtures/cjson/list.* 16 | test/fixtures/rust/target 17 | test/fixtures/java/target 18 | test/fixtures/java-lombok/target 19 | 20 | packages/*/dist 21 | packages/*/node_modules 22 | 23 | *.log 24 | /test/elm/libsysconfcpus/ 25 | /test/runs 26 | test/fixtures/cplusplus/json.hpp 27 | /dist 28 | test/fixtures/objective-c/quicktype 29 | *.xcbkptlist 30 | *.xcuserstate 31 | /bin 32 | /.node-persist 33 | /.vs 34 | .idea 35 | .DS_Store 36 | /.bsp 37 | .metals 38 | .scala-build 39 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v22.14.0 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Place your settings in this file to overwrite default and user settings. 3 | "editor.formatOnSave": true, 4 | "search.exclude": { 5 | "**/.git": true, 6 | "**/node_modules": true, 7 | "**/bower_components": true, 8 | "**/tmp": true, 9 | "output": true, 10 | "**/obj": true, 11 | "**/bin": true, 12 | "test/inputs": true, 13 | "test/runs": true, 14 | "app/build": true, 15 | "elm-stuff": true, 16 | "dist": true 17 | }, 18 | "explorer.excludeGitIgnore": false, 19 | "java.configuration.updateBuildConfiguration": "automatic", 20 | 21 | "files.associations": { 22 | "*.schema": "jsonc" 23 | }, 24 | 25 | "[json]": { 26 | "editor.defaultFormatter": "biomejs.biome", 27 | "editor.wordWrap": "on", 28 | "editor.insertSpaces": true, 29 | "editor.tabSize": 4, 30 | "editor.detectIndentation": false 31 | }, 32 | "[jsonc]": { 33 | "editor.defaultFormatter": "esbenp.prettier-vscode", 34 | "editor.wordWrap": "on", 35 | "editor.insertSpaces": true, 36 | "editor.tabSize": 4, 37 | "editor.detectIndentation": false 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "ignore": [ 4 | "test/runs", 5 | "test/inputs", 6 | "dist", 7 | "node_modules", 8 | "packages/*/dist", 9 | "packages/*/node_modules" 10 | ] 11 | }, 12 | "formatter": { 13 | "indentStyle": "space", 14 | "indentWidth": 4 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /doc/PostmanCollection.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "description": "Postman collection", 4 | "$ref": "#/definitions/collection", 5 | "definitions": { 6 | "group": { 7 | "type": "object", 8 | "properties": { 9 | "item": { 10 | "type": "array", 11 | "items": { 12 | "$ref": "#/definitions/collection" 13 | } 14 | } 15 | } 16 | }, 17 | "item": { 18 | "type": "object", 19 | "properties": { 20 | "name": { "type": "string" }, 21 | "response": { 22 | "type": "array", 23 | "items": { 24 | "$ref": "#/definitions/response" 25 | } 26 | } 27 | } 28 | }, 29 | "response": { 30 | "type": "object", 31 | "properties": { 32 | "body": { "type": "string" } 33 | } 34 | }, 35 | "collection": { 36 | "oneOf": [ 37 | { "$ref": "#/definitions/group" }, 38 | { "$ref": "#/definitions/item" } 39 | ] 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /media/faq/disable-detect-maps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/media/faq/disable-detect-maps.png -------------------------------------------------------------------------------- /media/faq/options-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/media/faq/options-panel.png -------------------------------------------------------------------------------- /packages/quicktype-core/env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $PUBLISH == true ]]; then 4 | echo 'HAS PUBLISH, exit' 5 | exit 0 6 | fi 7 | 8 | if [[ $CI ]]; then 9 | if [[ "$OSTYPE" == "darwin"* ]]; then 10 | grep -rl '$fetch' src | xargs sed -i '' -e 's/$fetch/$fetch.ci/g' 11 | else 12 | grep -rl '$fetch' src | xargs sed -i -e 's/$fetch/$fetch.ci/g' 13 | fi 14 | fi 15 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/Annotation.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-extraneous-class 2 | export class AnnotationData {} 3 | 4 | export class IssueAnnotationData extends AnnotationData { 5 | public constructor(public readonly message: string) { 6 | super(); 7 | } 8 | } 9 | 10 | export const anyTypeIssueAnnotation = new IssueAnnotationData( 11 | "quicktype cannot infer this type because there is no data about it in the input.", 12 | ); 13 | export const nullTypeIssueAnnotation = new IssueAnnotationData( 14 | "The only value for this in the input is null, which means you probably need a more complete input sample.", 15 | ); 16 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/Type/ProvenanceTypeAttributeKind.ts: -------------------------------------------------------------------------------- 1 | import { setUnionManyInto } from "collection-utils"; 2 | 3 | import { TypeAttributeKind } from "../attributes/TypeAttributes"; 4 | 5 | import type { TypeKind } from "./TransformedStringType"; 6 | 7 | // FIXME: Don't infer provenance. All original types should be present in 8 | // non-inferred form in the final graph. 9 | class ProvenanceTypeAttributeKind extends TypeAttributeKind> { 10 | public constructor() { 11 | super("provenance"); 12 | } 13 | 14 | public appliesToTypeKind(_kind: TypeKind): boolean { 15 | return true; 16 | } 17 | 18 | public combine(arr: Array>): Set { 19 | return setUnionManyInto(new Set(), arr); 20 | } 21 | 22 | public makeInferred(p: Set): Set { 23 | return p; 24 | } 25 | 26 | public stringify(p: Set): string { 27 | return Array.from(p) 28 | .sort() 29 | .map((i) => i.toString()) 30 | .join(","); 31 | } 32 | } 33 | 34 | export const provenanceTypeAttributeKind: TypeAttributeKind> = 35 | new ProvenanceTypeAttributeKind(); 36 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/Type/TypeBuilderUtils.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type PrimitiveStringTypeKind, 3 | type TransformedStringTypeKind, 4 | transformedStringTypeKinds, 5 | } from "./TransformedStringType"; 6 | 7 | export type StringTypeMapping = ReadonlyMap< 8 | TransformedStringTypeKind, 9 | PrimitiveStringTypeKind 10 | >; 11 | 12 | export function stringTypeMappingGet( 13 | stm: StringTypeMapping, 14 | kind: TransformedStringTypeKind, 15 | ): PrimitiveStringTypeKind { 16 | const mapped = stm.get(kind); 17 | if (mapped === undefined) return "string"; 18 | return mapped; 19 | } 20 | 21 | let noStringTypeMapping: StringTypeMapping | undefined; 22 | 23 | export function getNoStringTypeMapping(): StringTypeMapping { 24 | if (noStringTypeMapping === undefined) { 25 | noStringTypeMapping = new Map( 26 | Array.from(transformedStringTypeKinds).map( 27 | (k) => 28 | [k, k] as [ 29 | TransformedStringTypeKind, 30 | PrimitiveStringTypeKind, 31 | ], 32 | ), 33 | ); 34 | } 35 | 36 | return noStringTypeMapping; 37 | } 38 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/Type/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Type"; 2 | export * from "./TypeBuilder"; 3 | export * from "./TypeGraph"; 4 | export * from "./TypeUtils"; 5 | 6 | // TODO: update this to type * post TS upgrade 7 | export * from "./TransformedStringType"; 8 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/input/FetchingJSONSchemaStore.ts: -------------------------------------------------------------------------------- 1 | import { parseJSON } from "../support/Support"; 2 | 3 | import { readFromFileOrURL } from "./io/NodeIO"; 4 | import { type JSONSchema, JSONSchemaStore } from "./JSONSchemaStore"; 5 | 6 | export class FetchingJSONSchemaStore extends JSONSchemaStore { 7 | public constructor(private readonly _httpHeaders?: string[]) { 8 | super(); 9 | } 10 | 11 | public async fetch(address: string): Promise { 12 | // console.log(`Fetching ${address}`); 13 | return parseJSON( 14 | await readFromFileOrURL(address, this._httpHeaders), 15 | "JSON Schema", 16 | address, 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/input/PathElement.ts: -------------------------------------------------------------------------------- 1 | export enum PathElementKind { 2 | Root = 1, 3 | KeyOrIndex = 2, 4 | Type = 3, 5 | Object = 4, 6 | } 7 | 8 | export type PathElement = 9 | | { kind: PathElementKind.Root } 10 | | { key: string; kind: PathElementKind.KeyOrIndex } 11 | | { index: number; kind: PathElementKind.Type } 12 | | { kind: PathElementKind.Object }; 13 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/input/io/$fetch.ci.ts: -------------------------------------------------------------------------------- 1 | console.info("=== RUNNING IN CI, USE FETCH.CI ==="); 2 | 3 | export const fetch = require("cross-fetch").default; 4 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/input/io/$fetch.ts: -------------------------------------------------------------------------------- 1 | import type CrossFetch from "cross-fetch"; 2 | 3 | let fetch: typeof CrossFetch; 4 | 5 | try { 6 | fetch = global.fetch ?? require("cross-fetch").default; 7 | } catch { 8 | fetch = require("cross-fetch").default; 9 | } 10 | 11 | export { fetch }; 12 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/input/io/get-stream/license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of the software in this 'get-stream' directory and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/CJSON/index.ts: -------------------------------------------------------------------------------- 1 | export { CJSONTargetLanguage, cJSONOptions } from "./language"; 2 | export { CJSONRenderer } from "./CJSONRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/CPlusPlus/index.ts: -------------------------------------------------------------------------------- 1 | export { CPlusPlusTargetLanguage, cPlusPlusOptions } from "./language"; 2 | export { CPlusPlusRenderer } from "./CPlusPlusRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/CSharp/constants.ts: -------------------------------------------------------------------------------- 1 | export const keywords = [ 2 | "abstract", 3 | "as", 4 | "base", 5 | "bool", 6 | "break", 7 | "byte", 8 | "case", 9 | "catch", 10 | "char", 11 | "checked", 12 | "class", 13 | "const", 14 | "continue", 15 | "decimal", 16 | "default", 17 | "delegate", 18 | "do", 19 | "double", 20 | "else", 21 | "enum", 22 | "event", 23 | "explicit", 24 | "extern", 25 | "false", 26 | "finally", 27 | "fixed", 28 | "float", 29 | "for", 30 | "foreach", 31 | "goto", 32 | "if", 33 | "implicit", 34 | "in", 35 | "int", 36 | "interface", 37 | "internal", 38 | "is", 39 | "lock", 40 | "long", 41 | "namespace", 42 | "new", 43 | "null", 44 | "object", 45 | "operator", 46 | "out", 47 | "override", 48 | "params", 49 | "private", 50 | "protected", 51 | "public", 52 | "readonly", 53 | "ref", 54 | "return", 55 | "sbyte", 56 | "sealed", 57 | "short", 58 | "sizeof", 59 | "stackalloc", 60 | "static", 61 | "string", 62 | "struct", 63 | "switch", 64 | "this", 65 | "throw", 66 | "true", 67 | "try", 68 | "typeof", 69 | "uint", 70 | "ulong", 71 | "unchecked", 72 | "unsafe", 73 | "ushort", 74 | "using", 75 | "virtual", 76 | "void", 77 | "volatile", 78 | "while", 79 | ] as const; 80 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/CSharp/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | CSharpTargetLanguage, 3 | cSharpOptions, 4 | newtonsoftCSharpOptions, 5 | systemTextJsonCSharpOptions, 6 | } from "./language"; 7 | export { CSharpRenderer } from "./CSharpRenderer"; 8 | export { NewtonsoftCSharpRenderer } from "./NewtonSoftCSharpRenderer"; 9 | export { SystemTextJsonCSharpRenderer } from "./SystemTextJsonCSharpRenderer"; 10 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Crystal/index.ts: -------------------------------------------------------------------------------- 1 | export { CrystalTargetLanguage } from "./language"; 2 | export { CrystalRenderer } from "./CrystalRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Crystal/language.ts: -------------------------------------------------------------------------------- 1 | import type { RenderContext } from "../../Renderer"; 2 | import { TargetLanguage } from "../../TargetLanguage"; 3 | 4 | import { CrystalRenderer } from "./CrystalRenderer"; 5 | 6 | export const crystalLanguageConfig = { 7 | displayName: "Crystal", 8 | names: ["crystal", "cr", "crystallang"], 9 | extension: "cr", 10 | } as const; 11 | 12 | export class CrystalTargetLanguage extends TargetLanguage< 13 | typeof crystalLanguageConfig 14 | > { 15 | public constructor() { 16 | super(crystalLanguageConfig); 17 | } 18 | 19 | protected makeRenderer(renderContext: RenderContext): CrystalRenderer { 20 | return new CrystalRenderer(this, renderContext); 21 | } 22 | 23 | protected get defaultIndentation(): string { 24 | return " "; 25 | } 26 | 27 | public getOptions(): {} { 28 | return {}; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Dart/constants.ts: -------------------------------------------------------------------------------- 1 | export const keywords = [ 2 | "abstract", 3 | "do", 4 | "import", 5 | "super", 6 | "as", 7 | "dynamic", 8 | "in", 9 | "switch", 10 | "assert", 11 | "else", 12 | "interface", 13 | "sync*", 14 | "async", 15 | "enum", 16 | "is", 17 | "this", 18 | "async*", 19 | "export", 20 | "library", 21 | "throw", 22 | "await", 23 | "external", 24 | "mixin", 25 | "true", 26 | "break", 27 | "extends", 28 | "new", 29 | "try", 30 | "case", 31 | "factory", 32 | "null", 33 | "typedef", 34 | "catch", 35 | "false", 36 | "operator", 37 | "var", 38 | "class", 39 | "final", 40 | "part", 41 | "void", 42 | "const", 43 | "finally", 44 | "rethrow", 45 | "while", 46 | "continue", 47 | "for", 48 | "return", 49 | "with", 50 | "covariant", 51 | "get", 52 | "set", 53 | "yield", 54 | "default", 55 | "if", 56 | "static", 57 | "yield*", 58 | "deferred", 59 | "implements", 60 | "int", 61 | "double", 62 | "bool", 63 | "Map", 64 | "List", 65 | "String", 66 | "File", 67 | "fromJson", 68 | "toJson", 69 | "fromMap", 70 | "toMap", 71 | ] as const; 72 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Dart/index.ts: -------------------------------------------------------------------------------- 1 | export { DartTargetLanguage, dartOptions } from "./language"; 2 | export { DartRenderer } from "./DartRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Elixir/index.ts: -------------------------------------------------------------------------------- 1 | export { ElixirTargetLanguage, elixirOptions } from "./language"; 2 | export { ElixirRenderer } from "./ElixirRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Elm/constants.ts: -------------------------------------------------------------------------------- 1 | export const forbiddenNames = [ 2 | "if", 3 | "then", 4 | "else", 5 | "case", 6 | "of", 7 | "let", 8 | "in", 9 | "infix", 10 | "type", 11 | "module", 12 | "where", 13 | "import", 14 | "exposing", 15 | "as", 16 | "port", 17 | "int", 18 | "float", 19 | "bool", 20 | "string", 21 | "Jenc", 22 | "Jdec", 23 | "Jpipe", 24 | "always", 25 | "identity", 26 | "Array", 27 | "List", 28 | "Dict", 29 | "Maybe", 30 | "map", 31 | "toList", 32 | "makeArrayEncoder", 33 | "makeDictEncoder", 34 | "makeNullableEncoder", 35 | "Int", 36 | "True", 37 | "False", 38 | "String", 39 | "Float", 40 | ] as const; 41 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Elm/index.ts: -------------------------------------------------------------------------------- 1 | export { ElmTargetLanguage, elmOptions } from "./language"; 2 | export { ElmRenderer } from "./ElmRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Golang/index.ts: -------------------------------------------------------------------------------- 1 | export { GoTargetLanguage, goOptions } from "./language"; 2 | export { GoRenderer } from "./GolangRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Haskell/constants.ts: -------------------------------------------------------------------------------- 1 | export const forbiddenNames = [ 2 | // reserved keywords 3 | "as", 4 | "case", 5 | "class", 6 | "data", 7 | "default", 8 | "deriving", 9 | "do", 10 | "else", 11 | "family", 12 | "forall", 13 | "foreign", 14 | "hiding", 15 | "if", 16 | "import", 17 | "in", 18 | "infix", 19 | "infixl", 20 | "infixr", 21 | "instance", 22 | "let", 23 | "of", 24 | "mdo", 25 | "module", 26 | "newtype", 27 | "proc", 28 | "qualified", 29 | "rec", 30 | "then", 31 | "type", 32 | "where", 33 | // in Prelude keywords ... 34 | "id", 35 | "Array", 36 | "HashMap", 37 | "Map", 38 | "Maybe", 39 | "Bool", 40 | "Int", 41 | "True", 42 | "False", 43 | "Enum", 44 | // Aeson types 45 | "encode", 46 | "decode", 47 | "text", 48 | "Text", 49 | "Value", 50 | "Object", 51 | "Result", 52 | "Series", 53 | "Error", 54 | ] as const; 55 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Haskell/index.ts: -------------------------------------------------------------------------------- 1 | export { HaskellTargetLanguage, haskellOptions } from "./language"; 2 | export { HaskellRenderer } from "./HaskellRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Haskell/utils.ts: -------------------------------------------------------------------------------- 1 | import { funPrefixNamer } from "../../Naming"; 2 | import { 3 | allLowerWordStyle, 4 | allUpperWordStyle, 5 | combineWords, 6 | firstUpperWordStyle, 7 | isAscii, 8 | isLetterOrUnderscore, 9 | isLetterOrUnderscoreOrDigit, 10 | legalizeCharacters, 11 | splitIntoWords, 12 | } from "../../support/Strings"; 13 | 14 | const legalizeName = legalizeCharacters( 15 | (cp) => isAscii(cp) && isLetterOrUnderscoreOrDigit(cp), 16 | ); 17 | 18 | function haskellNameStyle(original: string, upper: boolean): string { 19 | const words = splitIntoWords(original); 20 | return combineWords( 21 | words, 22 | legalizeName, 23 | upper ? firstUpperWordStyle : allLowerWordStyle, 24 | firstUpperWordStyle, 25 | upper ? allUpperWordStyle : allLowerWordStyle, 26 | allUpperWordStyle, 27 | "", 28 | isLetterOrUnderscore, 29 | ); 30 | } 31 | 32 | export const upperNamingFunction = funPrefixNamer("upper", (n) => 33 | haskellNameStyle(n, true), 34 | ); 35 | export const lowerNamingFunction = funPrefixNamer("lower", (n) => 36 | haskellNameStyle(n, false), 37 | ); 38 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JSONSchema/index.ts: -------------------------------------------------------------------------------- 1 | export { JSONSchemaTargetLanguage } from "./language"; 2 | export { JSONSchemaRenderer } from "./JSONSchemaRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JSONSchema/language.ts: -------------------------------------------------------------------------------- 1 | import type { RenderContext } from "../../Renderer"; 2 | import { TargetLanguage } from "../../TargetLanguage"; 3 | import { 4 | type StringTypeMapping, 5 | getNoStringTypeMapping, 6 | } from "../../Type/TypeBuilderUtils"; 7 | import type { LanguageName, RendererOptions } from "../../types"; 8 | 9 | import { JSONSchemaRenderer } from "./JSONSchemaRenderer"; 10 | 11 | export const JSONSchemaLanguageConfig = { 12 | displayName: "JSON Schema", 13 | names: ["schema", "json-schema"], 14 | extension: "schema", 15 | } as const; 16 | 17 | export class JSONSchemaTargetLanguage extends TargetLanguage< 18 | typeof JSONSchemaLanguageConfig 19 | > { 20 | public constructor() { 21 | super(JSONSchemaLanguageConfig); 22 | } 23 | 24 | public getOptions(): {} { 25 | return {}; 26 | } 27 | 28 | public get stringTypeMapping(): StringTypeMapping { 29 | return getNoStringTypeMapping(); 30 | } 31 | 32 | public get supportsOptionalClassProperties(): boolean { 33 | return true; 34 | } 35 | 36 | public get supportsFullObjectType(): boolean { 37 | return true; 38 | } 39 | 40 | protected makeRenderer( 41 | renderContext: RenderContext, 42 | _untypedOptionValues: RendererOptions, 43 | ): JSONSchemaRenderer { 44 | return new JSONSchemaRenderer(this, renderContext); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JSONSchema/utils.ts: -------------------------------------------------------------------------------- 1 | import { funPrefixNamer } from "../../Naming"; 2 | import { 3 | allUpperWordStyle, 4 | combineWords, 5 | firstUpperWordStyle, 6 | legalizeCharacters, 7 | splitIntoWords, 8 | } from "../../support/Strings"; 9 | 10 | export const namingFunction = funPrefixNamer("namer", jsonNameStyle); 11 | 12 | const legalizeName = legalizeCharacters( 13 | (cp) => cp >= 32 && cp < 128 && cp !== 0x2f /* slash */, 14 | ); 15 | 16 | function jsonNameStyle(original: string): string { 17 | const words = splitIntoWords(original); 18 | return combineWords( 19 | words, 20 | legalizeName, 21 | firstUpperWordStyle, 22 | firstUpperWordStyle, 23 | allUpperWordStyle, 24 | allUpperWordStyle, 25 | "", 26 | (_) => true, 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Java/constants.ts: -------------------------------------------------------------------------------- 1 | export const javaKeywords = [ 2 | "_", // as of release 9, '_' is a keyword, and may not be used as an identifier 3 | "Object", 4 | "Class", 5 | "System", 6 | "Long", 7 | "Double", 8 | "Boolean", 9 | "String", 10 | "List", 11 | "Map", 12 | "UUID", 13 | "Exception", 14 | "IOException", 15 | "Override", 16 | "abstract", 17 | "continue", 18 | "for", 19 | "new", 20 | "switch", 21 | "assert", 22 | "default", 23 | "goto", 24 | "package", 25 | "synchronized", 26 | "boolean", 27 | "do", 28 | "if", 29 | "private", 30 | "this", 31 | "break", 32 | "double", 33 | "implements", 34 | "protected", 35 | "throw", 36 | "byte", 37 | "else", 38 | "import", 39 | "public", 40 | "throws", 41 | "case", 42 | "enum", 43 | "instanceof", 44 | "return", 45 | "transient", 46 | "catch", 47 | "extends", 48 | "int", 49 | "short", 50 | "try", 51 | "char", 52 | "final", 53 | "interface", 54 | "static", 55 | "void", 56 | "class", 57 | "finally", 58 | "long", 59 | "strictfp", 60 | "volatile", 61 | "const", 62 | "float", 63 | "native", 64 | "super", 65 | "while", 66 | "null", 67 | "false", 68 | "true", 69 | ] as const; 70 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Java/index.ts: -------------------------------------------------------------------------------- 1 | export { JavaTargetLanguage, javaOptions } from "./language"; 2 | export { JavaRenderer } from "./JavaRenderer"; 3 | export { JacksonRenderer } from "./JavaJacksonRenderer"; 4 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JavaScript/index.ts: -------------------------------------------------------------------------------- 1 | export { JavaScriptTargetLanguage, javaScriptOptions } from "./language"; 2 | export { 3 | JavaScriptRenderer, 4 | type JavaScriptTypeAnnotations, 5 | } from "./JavaScriptRenderer"; 6 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JavaScript/utils.ts: -------------------------------------------------------------------------------- 1 | import { utf16LegalizeCharacters } from "../../support/Strings"; 2 | 3 | import { isES3IdentifierPart } from "./unicodeMaps"; 4 | 5 | export const legalizeName = utf16LegalizeCharacters(isES3IdentifierPart); 6 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/JavaScriptPropTypes/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | JavaScriptPropTypesTargetLanguage, 3 | javaScriptPropTypesOptions, 4 | } from "./language"; 5 | export { JavaScriptPropTypesRenderer } from "./JavaScriptPropTypesRenderer"; 6 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Kotlin/constants.ts: -------------------------------------------------------------------------------- 1 | export const keywords = [ 2 | "package", 3 | "as", 4 | "typealias", 5 | "class", 6 | "this", 7 | "super", 8 | "val", 9 | "var", 10 | "fun", 11 | "for", 12 | "null", 13 | "true", 14 | "false", 15 | "is", 16 | "in", 17 | "throw", 18 | "return", 19 | "break", 20 | "continue", 21 | "object", 22 | "if", 23 | "try", 24 | "else", 25 | "while", 26 | "do", 27 | "when", 28 | "interface", 29 | "typeof", 30 | "klaxon", 31 | "toJson", 32 | "Any", 33 | "Boolean", 34 | "Double", 35 | "Float", 36 | "Long", 37 | "Int", 38 | "Short", 39 | "System", 40 | "Byte", 41 | "String", 42 | "Array", 43 | "List", 44 | "Map", 45 | "Enum", 46 | "Class", 47 | "JsonObject", 48 | "JsonValue", 49 | "Converter", 50 | "Klaxon", 51 | ] as const; 52 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Kotlin/index.ts: -------------------------------------------------------------------------------- 1 | export { KotlinTargetLanguage, kotlinOptions } from "./language"; 2 | export { KotlinRenderer } from "./KotlinRenderer"; 3 | export { KotlinJacksonRenderer } from "./KotlinJacksonRenderer"; 4 | export { KotlinKlaxonRenderer } from "./KotlinKlaxonRenderer"; 5 | export { KotlinXRenderer } from "./KotlinXRenderer"; 6 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Objective-C/index.ts: -------------------------------------------------------------------------------- 1 | export { ObjectiveCTargetLanguage, objectiveCOptions } from "./language"; 2 | export { ObjectiveCRenderer } from "./ObjectiveCRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Php/index.ts: -------------------------------------------------------------------------------- 1 | export { PhpTargetLanguage, phpOptions } from "./language"; 2 | export { PhpRenderer } from "./PhpRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Pike/constants.ts: -------------------------------------------------------------------------------- 1 | export const keywords = [ 2 | "auto", 3 | "nomask", 4 | "final", 5 | "static", 6 | "extern", 7 | "private", 8 | "local", 9 | "public", 10 | "protected", 11 | "inline", 12 | "optional", 13 | "variant", 14 | "void", 15 | "mixed", 16 | "array", 17 | "__attribute__", 18 | "__deprecated__", 19 | "mapping", 20 | "multiset", 21 | "object", 22 | "function", 23 | "__func__", 24 | "program", 25 | "string", 26 | "float", 27 | "int", 28 | "enum", 29 | "typedef", 30 | "if", 31 | "do", 32 | "for", 33 | "while", 34 | "else", 35 | "foreach", 36 | "catch", 37 | "gauge", 38 | "class", 39 | "break", 40 | "case", 41 | "const", 42 | "constant", 43 | "continue", 44 | "default", 45 | "import", 46 | "inherit", 47 | "lambda", 48 | "predef", 49 | "return", 50 | "sscanf", 51 | "switch", 52 | "typeof", 53 | "global", 54 | ] as const; 55 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Pike/index.ts: -------------------------------------------------------------------------------- 1 | export { PikeTargetLanguage, pikeOptions } from "./language"; 2 | export { PikeRenderer } from "./PikeRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Pike/language.ts: -------------------------------------------------------------------------------- 1 | import type { RenderContext } from "../../Renderer"; 2 | import { TargetLanguage } from "../../TargetLanguage"; 3 | 4 | import { PikeRenderer } from "./PikeRenderer"; 5 | 6 | export const pikeOptions = {}; 7 | 8 | export const pikeLanguageConfig = { 9 | displayName: "Pike", 10 | names: ["pike", "pikelang"], 11 | extension: "pmod", 12 | } as const; 13 | 14 | export class PikeTargetLanguage extends TargetLanguage< 15 | typeof pikeLanguageConfig 16 | > { 17 | public constructor() { 18 | super(pikeLanguageConfig); 19 | } 20 | 21 | public getOptions(): {} { 22 | return {}; 23 | } 24 | 25 | protected makeRenderer(renderContext: RenderContext): PikeRenderer { 26 | return new PikeRenderer(this, renderContext); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Pike/utils.ts: -------------------------------------------------------------------------------- 1 | import { funPrefixNamer } from "../../Naming"; 2 | import { 3 | isLetterOrUnderscoreOrDigit, 4 | legalizeCharacters, 5 | makeNameStyle, 6 | } from "../../support/Strings"; 7 | 8 | const legalizeName = legalizeCharacters(isLetterOrUnderscoreOrDigit); 9 | export const enumNamingFunction = funPrefixNamer( 10 | "enumNamer", 11 | makeNameStyle("upper-underscore", legalizeName), 12 | ); 13 | export const namingFunction = funPrefixNamer( 14 | "genericNamer", 15 | makeNameStyle("underscore", legalizeName), 16 | ); 17 | export const namedTypeNamingFunction = funPrefixNamer( 18 | "typeNamer", 19 | makeNameStyle("pascal", legalizeName), 20 | ); 21 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Python/constants.ts: -------------------------------------------------------------------------------- 1 | export const forbiddenTypeNames = [ 2 | "Any", 3 | "True", 4 | "False", 5 | "None", 6 | "Enum", 7 | "List", 8 | "Dict", 9 | "Optional", 10 | "Union", 11 | "Iterable", 12 | "Type", 13 | "TypeVar", 14 | "T", 15 | "EnumT", 16 | ] as const; 17 | 18 | export const forbiddenPropertyNames = [ 19 | "and", 20 | "as", 21 | "assert", 22 | "async", 23 | "await", 24 | "bool", 25 | "break", 26 | "class", 27 | "continue", 28 | "datetime", 29 | "def", 30 | "del", 31 | "dict", 32 | "elif", 33 | "else", 34 | "except", 35 | "finally", 36 | "float", 37 | "for", 38 | "from", 39 | "global", 40 | "if", 41 | "import", 42 | "in", 43 | "int", 44 | "is", 45 | "lambda", 46 | "nonlocal", 47 | "not", 48 | "or", 49 | "pass", 50 | "print", 51 | "raise", 52 | "return", 53 | "self", 54 | "str", 55 | "try", 56 | "while", 57 | "with", 58 | "yield", 59 | ] as const; 60 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Python/index.ts: -------------------------------------------------------------------------------- 1 | export { PythonTargetLanguage, pythonOptions } from "./language"; 2 | export { PythonRenderer } from "./PythonRenderer"; 3 | export { JSONPythonRenderer } from "./JSONPythonRenderer"; 4 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Ruby/index.ts: -------------------------------------------------------------------------------- 1 | export { RubyTargetLanguage, rubyOptions } from "./language"; 2 | export { RubyRenderer } from "./RubyRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Rust/index.ts: -------------------------------------------------------------------------------- 1 | export { RustTargetLanguage, rustOptions } from "./language"; 2 | export { RustRenderer } from "./RustRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Scala3/UpickleRenderer.ts: -------------------------------------------------------------------------------- 1 | import { Scala3Renderer } from "./Scala3Renderer"; 2 | 3 | export class UpickleRenderer extends Scala3Renderer { 4 | protected emitClassDefinitionMethods(): void { 5 | this.emitLine(") derives ReadWriter "); 6 | } 7 | 8 | protected emitHeader(): void { 9 | super.emitHeader(); 10 | 11 | this.emitLine("import upickle.default.*"); 12 | this.ensureBlankLine(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Scala3/index.ts: -------------------------------------------------------------------------------- 1 | export { Scala3TargetLanguage, scala3Options } from "./language"; 2 | export { Scala3Renderer } from "./Scala3Renderer"; 3 | export { CirceRenderer } from "./CirceRenderer"; 4 | export { UpickleRenderer } from "./UpickleRenderer"; 5 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Smithy4s/constants.ts: -------------------------------------------------------------------------------- 1 | // Use backticks for param names with symbols 2 | export const invalidSymbols = [ 3 | ":", 4 | "-", 5 | "+", 6 | "!", 7 | "@", 8 | "#", 9 | "%", 10 | "^", 11 | "&", 12 | "*", 13 | "(", 14 | ")", 15 | ">", 16 | "<", 17 | "/", 18 | ";", 19 | "'", 20 | '"', 21 | "{", 22 | "}", 23 | ":", 24 | "~", 25 | "`", 26 | ".", 27 | ] as const; 28 | 29 | export const keywords = [ 30 | "abstract", 31 | "case", 32 | "catch", 33 | "do", 34 | "else", 35 | "export", 36 | "false", 37 | "final", 38 | "finally", 39 | "for", 40 | "forSome", 41 | "if", 42 | "implicit", 43 | "import", 44 | "new", 45 | "override", 46 | "package", 47 | "private", 48 | "protected", 49 | "return", 50 | "sealed", 51 | "super", 52 | "this", 53 | "then", 54 | "throw", 55 | "trait", 56 | "try", 57 | "true", 58 | "val", 59 | "var", 60 | "while", 61 | "with", 62 | "yield", 63 | "Any", 64 | "Boolean", 65 | "Double", 66 | "Float", 67 | "Long", 68 | "Int", 69 | "Short", 70 | "System", 71 | "Byte", 72 | "String", 73 | "Array", 74 | "List", 75 | "Map", 76 | "Enum", 77 | ] as const; 78 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Smithy4s/index.ts: -------------------------------------------------------------------------------- 1 | export { SmithyTargetLanguage, smithyOptions } from "./language"; 2 | export { Smithy4sRenderer } from "./Smithy4sRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/Swift/index.ts: -------------------------------------------------------------------------------- 1 | export { SwiftTargetLanguage, swiftOptions } from "./language"; 2 | export { SwiftRenderer } from "./SwiftRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/TypeScriptEffectSchema/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | TypeScriptEffectSchemaTargetLanguage, 3 | typeScriptEffectSchemaOptions, 4 | } from "./language"; 5 | export { TypeScriptEffectSchemaRenderer } from "./TypeScriptEffectSchemaRenderer"; 6 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/TypeScriptFlow/index.ts: -------------------------------------------------------------------------------- 1 | export { FlowRenderer } from "./FlowRenderer"; 2 | export { TypeScriptRenderer } from "./TypeScriptRenderer"; 3 | export { 4 | FlowTargetLanguage, 5 | TypeScriptTargetLanguage, 6 | tsFlowOptions, 7 | } from "./language"; 8 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/TypeScriptFlow/utils.ts: -------------------------------------------------------------------------------- 1 | import { utf16StringEscape } from "../../support/Strings"; 2 | import { isES3IdentifierStart } from "../JavaScript/unicodeMaps"; 3 | import { legalizeName } from "../JavaScript/utils"; 4 | 5 | export const tsFlowTypeAnnotations = { 6 | any: ": any", 7 | anyArray: ": any[]", 8 | anyMap: ": { [k: string]: any }", 9 | string: ": string", 10 | stringArray: ": string[]", 11 | boolean: ": boolean", 12 | }; 13 | 14 | export function quotePropertyName(original: string): string { 15 | const escaped = utf16StringEscape(original); 16 | const quoted = `"${escaped}"`; 17 | 18 | if (original.length === 0) { 19 | return quoted; 20 | } else if (!isES3IdentifierStart(original.codePointAt(0) as number)) { 21 | return quoted; 22 | } else if (escaped !== original) { 23 | return quoted; 24 | } else if (legalizeName(original) !== original) { 25 | return quoted; 26 | } else { 27 | return original; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/TypeScriptZod/index.ts: -------------------------------------------------------------------------------- 1 | export { TypeScriptZodTargetLanguage, typeScriptZodOptions } from "./language"; 2 | export { TypeScriptZodRenderer } from "./TypeScriptZodRenderer"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./CJSON"; 2 | export * from "./CPlusPlus"; 3 | export * from "./Crystal"; 4 | export * from "./CSharp"; 5 | export * from "./Dart"; 6 | export * from "./Elixir"; 7 | export * from "./Elm"; 8 | export * from "./Golang"; 9 | export * from "./Haskell"; 10 | export * from "./Java"; 11 | export * from "./JavaScript"; 12 | export * from "./JavaScriptPropTypes"; 13 | export * from "./JSONSchema"; 14 | export * from "./Kotlin"; 15 | export * from "./Objective-C"; 16 | export * from "./Php"; 17 | export * from "./Pike"; 18 | export * from "./Python"; 19 | export * from "./Ruby"; 20 | export * from "./Rust"; 21 | export * from "./Scala3"; 22 | export * from "./Smithy4s"; 23 | export * from "./Swift"; 24 | export * from "./TypeScriptFlow"; 25 | export * from "./TypeScriptEffectSchema"; 26 | export * from "./TypeScriptZod"; 27 | 28 | export { 29 | all as defaultTargetLanguages, 30 | languageNamed, 31 | isLanguageName, 32 | } from "./All"; 33 | export type { LanguageName, LanguageDisplayName } from "./types"; 34 | export type { RendererOptions } from "./options.types"; 35 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/options.types.ts: -------------------------------------------------------------------------------- 1 | import type { OptionMap } from "../RendererOptions"; 2 | 3 | import type { LanguageName, LanguageNameMap } from "./types"; 4 | 5 | export type LanguageRawOptionMap = Readonly<{ 6 | [Lang in keyof LanguageNameMap]: ReturnType< 7 | LanguageNameMap[Lang]["getOptions"] 8 | >; 9 | }>; 10 | 11 | export type LanguageOptionMap = Readonly<{ 12 | [Lang in keyof LanguageRawOptionMap]: OptionMap; 13 | }>; 14 | 15 | export type RendererOptions< 16 | Lang extends LanguageName = LanguageName, 17 | Options = LanguageOptionMap[Lang], 18 | > = { 19 | -readonly [K in keyof Options]: Options[K]; 20 | }; 21 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/language/types.ts: -------------------------------------------------------------------------------- 1 | import type { TargetLanguage } from "../TargetLanguage"; 2 | 3 | import type { all } from "./All"; 4 | 5 | type AllLanguages = (typeof all)[number]; 6 | 7 | export type LanguageDisplayName< 8 | Language extends TargetLanguage = AllLanguages, 9 | > = Language["displayName"]; 10 | export type LanguageName = 11 | Language["names"][number]; 12 | 13 | export type LanguageDisplayNameMap = { 14 | [Language in AllLanguages as LanguageDisplayName]: Language; 15 | }; 16 | export type LanguageNameMap = { 17 | [Language in AllLanguages as LanguageName]: Language; 18 | }; 19 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/support/Acronyms.ts: -------------------------------------------------------------------------------- 1 | import { EnumOption } from "../RendererOptions"; 2 | 3 | import { 4 | allLowerWordStyle, 5 | allUpperWordStyle, 6 | firstUpperWordStyle, 7 | originalWord, 8 | } from "./Strings"; 9 | 10 | export enum AcronymStyleOptions { 11 | Camel = "camel", 12 | Lower = "lowerCase", 13 | Original = "original", 14 | Pascal = "pascal", 15 | } 16 | 17 | export const acronymOption = (defaultOption: AcronymStyleOptions) => new EnumOption( 18 | "acronym-style", 19 | "Acronym naming style", 20 | { 21 | [AcronymStyleOptions.Original]: AcronymStyleOptions.Original, 22 | [AcronymStyleOptions.Pascal]: AcronymStyleOptions.Pascal, 23 | [AcronymStyleOptions.Camel]: AcronymStyleOptions.Camel, 24 | [AcronymStyleOptions.Lower]: AcronymStyleOptions.Lower, 25 | } as const, 26 | defaultOption, 27 | "secondary", 28 | ); 29 | 30 | const options = { 31 | [AcronymStyleOptions.Pascal]: allUpperWordStyle, 32 | [AcronymStyleOptions.Camel]: firstUpperWordStyle, 33 | [AcronymStyleOptions.Original]: originalWord, 34 | [AcronymStyleOptions.Lower]: allLowerWordStyle, 35 | } as const; 36 | 37 | export function acronymStyle( 38 | style: AcronymStyle, 39 | ): (typeof options)[AcronymStyle] { 40 | return options[style]; 41 | } 42 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/support/Comments.ts: -------------------------------------------------------------------------------- 1 | import type { Sourcelike } from "../Source"; 2 | 3 | export interface CommentOptions { 4 | afterComment?: string; 5 | beforeComment?: string; 6 | firstLineStart?: string; 7 | lineEnd?: string; 8 | lineStart?: string; 9 | } 10 | 11 | interface DescriptionBlockCommentConfig { 12 | descriptionBlock: Sourcelike[]; 13 | } 14 | interface InlineCommentConfig { 15 | lines: Sourcelike[]; 16 | } 17 | type CustomCommentConfig = CommentOptions & { 18 | customLines: Sourcelike[]; 19 | }; 20 | 21 | export type CommentConfig = 22 | | DescriptionBlockCommentConfig 23 | | InlineCommentConfig 24 | | CustomCommentConfig; 25 | 26 | export type Comment = string | CommentConfig; 27 | 28 | export const isStringComment = (comment: Comment): comment is string => { 29 | return typeof comment === "string"; 30 | }; 31 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/support/Converters.ts: -------------------------------------------------------------------------------- 1 | import { EnumOption } from "../RendererOptions"; 2 | 3 | export enum ConvertersOptions { 4 | AllObjects = "all-objects", 5 | TopLevel = "top-level", 6 | } 7 | 8 | export function convertersOption() { 9 | return new EnumOption( 10 | "converters", 11 | "Which converters to generate (top-level by default)", 12 | { 13 | [ConvertersOptions.TopLevel]: ConvertersOptions.TopLevel, 14 | [ConvertersOptions.AllObjects]: ConvertersOptions.AllObjects, 15 | } as const, 16 | ConvertersOptions.TopLevel, 17 | "secondary", 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /packages/quicktype-core/src/types.ts: -------------------------------------------------------------------------------- 1 | export * from "./language/types"; 2 | export * from "./language/options.types"; 3 | -------------------------------------------------------------------------------- /packages/quicktype-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "lib": ["es6", "esnext.asynciterable"], 6 | "allowJs": false, 7 | "declaration": true, 8 | "strict": true, 9 | "outDir": "dist", 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "esModuleInterop": true, 14 | "baseUrl": "src" 15 | }, 16 | "include": ["src"] 17 | } 18 | -------------------------------------------------------------------------------- /packages/quicktype-graphql-input/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quicktype-graphql-input", 3 | "version": "18.0.15", 4 | "package": "Package for using GraphQL as an input language to quicktype", 5 | "license": "Apache-2.0", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "repository": "https://github.com/quicktype/quicktype", 9 | "scripts": { 10 | "clean": "rm -rf dist node_modules *~", 11 | "build": "tsc" 12 | }, 13 | "dependencies": { 14 | "quicktype-core": "file:../quicktype-core", 15 | "collection-utils": "^1.0.1", 16 | "graphql": "^0.11.7" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "~22.14.0", 20 | "@types/graphql": "^0.11.7", 21 | "typescript": "~5.8.3" 22 | }, 23 | "files": ["dist"] 24 | } 25 | -------------------------------------------------------------------------------- /packages/quicktype-graphql-input/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "lib": ["es6", "esnext.asynciterable"], 6 | "allowJs": false, 7 | "declaration": true, 8 | "strict": true, 9 | "alwaysStrict": true, 10 | "outDir": "dist", 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "esModuleInterop": true, 14 | "baseUrl": "src" 15 | }, 16 | "include": ["src"] 17 | } 18 | -------------------------------------------------------------------------------- /packages/quicktype-typescript-input/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quicktype-typescript-input", 3 | "version": "18.0.15", 4 | "description": "Package for using TypeScript as an input language to quicktype", 5 | "license": "Apache-2.0", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "repository": "https://github.com/quicktype/quicktype", 9 | "scripts": { 10 | "clean": "rm -rf dist node_modules *~", 11 | "build": "tsc" 12 | }, 13 | "dependencies": { 14 | "quicktype-core": "file:../quicktype-core", 15 | "typescript": "4.9.5", 16 | "@mark.probst/typescript-json-schema": "0.55.0" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "~22.14.0" 20 | }, 21 | "files": ["dist"] 22 | } 23 | -------------------------------------------------------------------------------- /packages/quicktype-typescript-input/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "lib": ["es6", "esnext.asynciterable"], 6 | "allowJs": false, 7 | "declaration": true, 8 | "strict": true, 9 | "alwaysStrict": true, 10 | "outDir": "dist", 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "esModuleInterop": true, 14 | "baseUrl": "src" 15 | }, 16 | "include": ["src"] 17 | } 18 | -------------------------------------------------------------------------------- /packages/quicktype-vscode/.gitignore: -------------------------------------------------------------------------------- 1 | out -------------------------------------------------------------------------------- /packages/quicktype-vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules 3 | out/ 4 | src/ 5 | tsconfig.json -------------------------------------------------------------------------------- /packages/quicktype-vscode/media/demo-interactive.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/packages/quicktype-vscode/media/demo-interactive.gif -------------------------------------------------------------------------------- /packages/quicktype-vscode/media/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/packages/quicktype-vscode/media/demo.gif -------------------------------------------------------------------------------- /packages/quicktype-vscode/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/packages/quicktype-vscode/media/icon.png -------------------------------------------------------------------------------- /packages/quicktype-vscode/quicktype-23.0.122.vsix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/packages/quicktype-vscode/quicktype-23.0.122.vsix -------------------------------------------------------------------------------- /packages/quicktype-vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": ["es6", "esnext.asynciterable"], 7 | "sourceMap": true, 8 | "rootDir": ".", 9 | "allowJs": false, 10 | "strict": true, 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "esModuleInterop": true 14 | }, 15 | "exclude": ["node_modules", ".vscode-test"] 16 | } 17 | -------------------------------------------------------------------------------- /script/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # docker pull schani/quicktype 4 | docker build --cache-from quicktype -t quicktype . 5 | docker run -it \ 6 | -p 3000:3000 \ 7 | --volume=$PWD:/quicktype \ 8 | --workdir="/quicktype" \ 9 | --entrypoint=/bin/bash \ 10 | quicktype 11 | -------------------------------------------------------------------------------- /script/dev.ps1: -------------------------------------------------------------------------------- 1 | # docker pull schani/quicktype 2 | docker build --cache-from quicktype -t quicktype . 3 | 4 | docker run -it ` 5 | -p 3000:3000 ` 6 | --volume=$($PWD.path):/quicktype ` 7 | --workdir="/quicktype" ` 8 | --entrypoint=/bin/bash ` 9 | quicktype 10 | -------------------------------------------------------------------------------- /script/homebrew-update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash -e 2 | 3 | # Create a GitHub token with public_repo scope: https://github.com/settings/tokens/new 4 | # Then set it as: 5 | # HOMEBREW_GITHUB_TOKEN=... 6 | 7 | URL=$(npm info quicktype --json | jq -r .dist.tarball) 8 | SHA=$(curl $URL | shasum -a 256 | cut -d " " -f1) 9 | brew bump-formula-pr --strict quicktype --url="$URL" --sha256="$SHA" 10 | -------------------------------------------------------------------------------- /script/make-encoded-markov-chain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./generate-markov-corpus.py >/tmp/corpus.txt 4 | ../script/quickertype --build-markov-chain /tmp/corpus.txt >/tmp/markov.json 5 | gzip -9 /tmp/markov.json 6 | echo -n 'export const encodedMarkovChain = "' 7 | base64 /tmp/markov.json.gz | tr -d '\n' 8 | echo '";' 9 | -------------------------------------------------------------------------------- /script/make-encoded-ts-lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f /tmp/lib.d.ts /tmp/lib.d.ts.gz 4 | cp ../data/lib.d.ts /tmp/lib.d.ts 5 | gzip -9 /tmp/lib.d.ts 6 | echo -n 'export const encodedDefaultTypeScriptLibrary = "' 7 | base64 /tmp/lib.d.ts.gz | tr -d '\n' 8 | echo '";' 9 | -------------------------------------------------------------------------------- /script/patch-npm-version.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ts-node 2 | 3 | // If the version in package.json is less than or equal to 4 | // the published version on npm, set the version to a patch 5 | // on top of the npm version so we can publish. 6 | 7 | import * as shell from "shelljs"; 8 | import * as semver from "semver"; 9 | 10 | function exec(command: string) { 11 | const result = shell.exec(command, { silent: true }); 12 | return (result.stdout as string).trim(); 13 | } 14 | 15 | const PUBLISHED = (() => { 16 | // Get the highest published version of any tag 17 | const all = JSON.parse(exec(`npm show quicktype versions --json`)); 18 | return all[all.length - 1]; 19 | })(); 20 | 21 | const CURRENT = exec(`npm version`).match(/quicktype: '(.+)'/)![1]; 22 | switch (semver.compare(CURRENT, PUBLISHED)) { 23 | case -1: 24 | console.error( 25 | `* package.json version is ${CURRENT} but ${PUBLISHED} is published. Patching...`, 26 | ); 27 | exec(`npm version ${PUBLISHED} --force --no-git-tag-version`); 28 | shell.exec(`npm version patch --no-git-tag-version`); 29 | break; 30 | case 0: 31 | console.error( 32 | `* package.json version is ${CURRENT} but ${PUBLISHED} is published. Patching...`, 33 | ); 34 | shell.exec(`npm version patch --no-git-tag-version`); 35 | break; 36 | default: 37 | // Greater than published, nothing to do 38 | break; 39 | } 40 | -------------------------------------------------------------------------------- /script/publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | ./script/patch-npm-version.ts 6 | 7 | VERSION=$(jq -r '.version' package.json ) 8 | npm version $VERSION --workspaces --force 9 | 10 | # Publish core 11 | pushd packages/quicktype-core 12 | npm publish 13 | popd 14 | 15 | # Publish typescript input 16 | pushd packages/quicktype-typescript-input 17 | jq --arg version $VERSION \ 18 | '.dependencies."quicktype-core" = $version' \ 19 | package.json > package.1.json 20 | mv package.1.json package.json 21 | npm publish 22 | popd 23 | 24 | # Publish graphql input 25 | pushd packages/quicktype-graphql-input 26 | jq --arg version $VERSION \ 27 | '.dependencies."quicktype-core" = $version' \ 28 | package.json > package.1.json 29 | mv package.1.json package.json 30 | npm publish 31 | popd 32 | 33 | # Publish quicktype 34 | jq --arg version $VERSION \ 35 | '.dependencies."quicktype-core" = $version | .dependencies."quicktype-graphql-input" = $version | .dependencies."quicktype-typescript-input" = $version' \ 36 | package.json > package.1.json 37 | mv package.1.json package.json 38 | npm publish 39 | 40 | 41 | # Publish vscode extension 42 | pushd packages/quicktype-vscode 43 | npm run pub 44 | popd 45 | -------------------------------------------------------------------------------- /script/quickesttype: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This runs quicktype, without building. 4 | # 5 | # In practice this runs an order of magnitude faster. 6 | 7 | SCRIPTDIR=$(dirname "$0") 8 | 9 | SKIP_BUILD=true "$SCRIPTDIR/quicktype" "$@" 10 | -------------------------------------------------------------------------------- /script/quicktype: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This runs quicktype, ensuring dependencies are installed 4 | # and rebuilding quicktype first. 5 | # 6 | # Use script/quickesttype to skip reinstalling dependencies 7 | # and rebuilding PureScript for 10s faster runs if you 8 | # are just working on TargetLanguage code in TypeScript. 9 | 10 | SCRIPTDIR=$(dirname "$0") 11 | BASEDIR="$SCRIPTDIR/.." 12 | 13 | if [ x"$SKIP_BUILD" = x ] ; then 14 | ( cd "$BASEDIR" ; npm run build &>/dev/null ) 15 | fi 16 | node --stack_trace_limit=100 --max-old-space-size=4096 "$BASEDIR/dist/index.js" "$@" 17 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export NODE_PATH=`pwd`/node_modules 4 | export PATH=`pwd`/node_modules/.bin:$PATH 5 | export TZ=UTC 6 | ts-node --project test/tsconfig.json test/test.ts $@ 7 | -------------------------------------------------------------------------------- /script/watch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | watch "script/quicktype $@" src packages/*/src 4 | -------------------------------------------------------------------------------- /src/TypeSource.ts: -------------------------------------------------------------------------------- 1 | import type { Readable } from "readable-stream"; 2 | 3 | import type { JSONSchemaSourceData, JSONSourceData } from "quicktype-core"; 4 | import type { GraphQLSourceData } from "quicktype-graphql-input"; 5 | 6 | export interface JSONTypeSource extends JSONSourceData { 7 | kind: "json"; 8 | } 9 | 10 | export interface SchemaTypeSource extends JSONSchemaSourceData { 11 | kind: "schema"; 12 | } 13 | 14 | export interface GraphQLTypeSource extends GraphQLSourceData { 15 | kind: "graphql"; 16 | } 17 | 18 | export type TypeSource = GraphQLTypeSource | JSONTypeSource | SchemaTypeSource; 19 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | /java/.idea/workspace.xml 4 | /java/out -------------------------------------------------------------------------------- /test/compare-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8 | 9 | DIR1="$1" 10 | DIR2="$2" 11 | DIFFDIR="$3" 12 | 13 | for fn in `cd "$DIR1" ; find . -type f` ; do 14 | fdir=`dirname "$fn"` 15 | mkdir -p "$DIFFDIR/$fdir" 16 | f1="$DIR1/$fn" 17 | f2="$DIR2/$fn" 18 | if [ -f "$f2" ] ; then 19 | of="$DIFFDIR/$fn.diff" 20 | set +e 21 | diff -u "$f1" "$f2" >"$of" 22 | set -e 23 | stat=`diffstat -s "$of"` 24 | lines=`cat "$of" | wc -l` 25 | echo "$lines $stat $fn" 26 | else 27 | echo "missing $fn" 28 | fi 29 | done 30 | -------------------------------------------------------------------------------- /test/fixtures/cplusplus/Generators.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a dummy header, which will or will NOT be overwritten 3 | * depending on how you call quicktype to generate the source code 4 | * [multi source or single source] 5 | */ 6 | #pragma once 7 | -------------------------------------------------------------------------------- /test/fixtures/cplusplus/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "TopLevel.hpp" 7 | #include "Generators.hpp" 8 | 9 | using quicktype::TopLevel; 10 | using nlohmann::json; 11 | 12 | int main(int argc, const char * argv[]) { 13 | if (argc != 2) { 14 | std::cerr << "Usage: " << argv[0] << " FILE"; 15 | return 1; 16 | } 17 | 18 | std::ifstream t(argv[1]); 19 | std::string str((std::istreambuf_iterator(t)), 20 | std::istreambuf_iterator()); 21 | 22 | TopLevel tl = json::parse(str); 23 | json j2 = tl; 24 | 25 | std::cout << j2 << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/crystal/main.cr: -------------------------------------------------------------------------------- 1 | require "json" 2 | require "./TopLevel" 3 | 4 | json = File.read(ARGV[0].not_nil!) 5 | top = TopLevel.from_json(json) 6 | 7 | puts top.to_json 8 | -------------------------------------------------------------------------------- /test/fixtures/csharp-SystemTextJson/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | -------------------------------------------------------------------------------- /test/fixtures/csharp-SystemTextJson/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/test.dll", 14 | "args": [], 15 | "cwd": "${workspaceRoot}", 16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window 17 | "console": "internalConsole", 18 | "stopAtEntry": false, 19 | "internalConsoleOptions": "openOnSessionStart" 20 | }, 21 | { 22 | "name": ".NET Core Attach", 23 | "type": "coreclr", 24 | "request": "attach", 25 | "processId": "${command:pickProcess}" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/csharp-SystemTextJson/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "build", 9 | "args": ["${workspaceRoot}/test.csproj"], 10 | "isBuildCommand": true, 11 | "problemMatcher": "$msCompile" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/csharp-SystemTextJson/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QuickType 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var path = args[0]; 10 | var json = System.IO.File.ReadAllText(path); 11 | var output = TopLevel.FromJson(json).ToJson(); 12 | Console.WriteLine("{0}", output); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/csharp-SystemTextJson/test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Exe 4 | net6 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/fixtures/csharp/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | -------------------------------------------------------------------------------- /test/fixtures/csharp/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/test.dll", 14 | "args": [], 15 | "cwd": "${workspaceRoot}", 16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window 17 | "console": "internalConsole", 18 | "stopAtEntry": false, 19 | "internalConsoleOptions": "openOnSessionStart" 20 | }, 21 | { 22 | "name": ".NET Core Attach", 23 | "type": "coreclr", 24 | "request": "attach", 25 | "processId": "${command:pickProcess}" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/fixtures/csharp/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "build", 9 | "args": ["${workspaceRoot}/test.csproj"], 10 | "isBuildCommand": true, 11 | "problemMatcher": "$msCompile" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/csharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace QuickType 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | var path = args[0]; 10 | var json = System.IO.File.ReadAllText(path); 11 | var output = TopLevel.FromJson(json).ToJson(); 12 | Console.WriteLine("{0}", output); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/csharp/test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Exe 4 | netcoreapp6.0 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/fixtures/dart/parser.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'TopLevel.dart'; 3 | 4 | void main(List arguments) async { 5 | final path = arguments[0]; 6 | new File(path).readAsString().then((String contents) async { 7 | final topLevel = topLevelFromJson(contents); 8 | final result = topLevelToJson(topLevel); 9 | stdout.write(result); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/elixir/.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | quick_type_test-*.tar 24 | 25 | # Temporary files, for example, from tests. 26 | /tmp/ 27 | -------------------------------------------------------------------------------- /test/fixtures/elixir/main.exs: -------------------------------------------------------------------------------- 1 | defmodule Main do 2 | def run do 3 | [file_path | _] = System.argv() 4 | 5 | file_path 6 | |> File.read!() 7 | |> TopLevel.from_json() 8 | |> TopLevel.to_json() 9 | |> IO.puts() 10 | end 11 | end 12 | 13 | Main.run() 14 | -------------------------------------------------------------------------------- /test/fixtures/elixir/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule QuickTypeTest.MixProject do 2 | use Mix.Project 3 | 4 | def project do 5 | [ 6 | app: :quick_type_test, 7 | version: "0.1.0", 8 | elixir: "~> 1.15", 9 | elixirc_paths: elixirc_paths(Mix.env()), 10 | elixirc_options: [ignore_module_conflict: true], 11 | start_permanent: Mix.env() == :prod, 12 | deps: deps() 13 | ] 14 | end 15 | 16 | # Run "mix help compile.app" to learn about applications. 17 | def application do 18 | [ 19 | extra_applications: [:logger] 20 | ] 21 | end 22 | 23 | defp elixirc_paths(_), do: ["./"] 24 | 25 | # Run "mix help deps" to learn about dependencies. 26 | defp deps do 27 | [ 28 | {:jason, "~> 1.2"} 29 | ] 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /test/fixtures/elixir/mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/elm/.gitignore: -------------------------------------------------------------------------------- 1 | /elm-stuff -------------------------------------------------------------------------------- /test/fixtures/elm/Main.elm: -------------------------------------------------------------------------------- 1 | port module Main exposing (..) 2 | 3 | -- this is required for the ports 4 | import Json.Decode exposing (decodeString) 5 | import QuickType 6 | 7 | port fromJS : (String -> msg) -> Sub msg 8 | port toJS : String -> Cmd msg 9 | 10 | type Msg 11 | = FromJS String 12 | 13 | update : Msg -> () -> ( (), Cmd Msg ) 14 | update msg _ = 15 | case msg of 16 | FromJS str -> 17 | case decodeString QuickType.quickType str of 18 | Ok r -> ((), toJS (QuickType.quickTypeToString r)) 19 | Err err -> ((), toJS ("Error: " ++ err)) 20 | 21 | subscriptions : () -> Sub Msg 22 | subscriptions _ = 23 | fromJS (FromJS) 24 | 25 | main : Program Never () Msg 26 | main = 27 | Platform.program 28 | { init = ( (), Cmd.none ) 29 | , update = update 30 | , subscriptions = subscriptions 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/elm/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": ["."], 7 | "exposed-modules": [], 8 | "dependencies": { 9 | "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0", 10 | "elm-lang/core": "5.1.1 <= v < 6.0.0", 11 | "elm-lang/html": "2.0.0 <= v < 3.0.0" 12 | }, 13 | "elm-version": "0.18.0 <= v < 0.19.0" 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/elm/runner.js: -------------------------------------------------------------------------------- 1 | const Elm = require("./elm.js"); 2 | const fs = require("fs"); 3 | 4 | const ports = Elm.Main.worker().ports; 5 | 6 | ports.toJS.subscribe((result) => { 7 | if (result.startsWith("Error: ")) { 8 | process.stderr.write(result + "\n", () => { 9 | process.exit(1); 10 | }); 11 | } else { 12 | process.stdout.write(result + "\n", () => { 13 | process.exit(0); 14 | }); 15 | } 16 | }); 17 | 18 | ports.fromJS.send(fs.readFileSync(process.argv[2], "utf8")); 19 | -------------------------------------------------------------------------------- /test/fixtures/flow/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [lints] 8 | 9 | [options] 10 | 11 | [strict] 12 | -------------------------------------------------------------------------------- /test/fixtures/flow/main.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const TopLevel = require("./TopLevel"); 4 | 5 | const fs = require("fs"); 6 | 7 | const sample = process.argv[2]; 8 | const json = fs.readFileSync(sample).toString(); 9 | 10 | const value = TopLevel.toTopLevel(json); 11 | const backToJson = TopLevel.topLevelToJson(value); 12 | 13 | console.log(backToJson); 14 | -------------------------------------------------------------------------------- /test/fixtures/golang/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "io/ioutil" 4 | import "log" 5 | import "os" 6 | 7 | func main() { 8 | bytes, err := ioutil.ReadAll(os.Stdin) 9 | if err != nil { 10 | log.Fatal(err) 11 | } 12 | 13 | t, err := UnmarshalTopLevel(bytes) 14 | if err != nil { 15 | log.Fatal(err) 16 | } 17 | 18 | bytes, err = t.Marshal() 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | 23 | n, err := os.Stdout.Write(bytes) 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | if n != len(bytes) { 28 | log.Fatal("Could not write output") 29 | } 30 | os.Stdout.Write([]byte("\n")) 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/haskell/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work 2 | *.cabal 3 | -------------------------------------------------------------------------------- /test/fixtures/haskell/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | module Main where 3 | 4 | import Data.Aeson (encode, decode) 5 | import QuickType 6 | import Data.Maybe (fromJust) 7 | import System.Environment 8 | import qualified Data.ByteString.Lazy as BS 9 | 10 | main :: IO () 11 | main = do 12 | args <- getArgs 13 | let filePath = head args 14 | content <- BS.readFile filePath 15 | let dec = decodeTopLevel content 16 | BS.putStr $ encode dec 17 | -------------------------------------------------------------------------------- /test/fixtures/haskell/QuickType.hs: -------------------------------------------------------------------------------- 1 | module QuickType where 2 | 3 | import Data.ByteString.Lazy (ByteString) 4 | 5 | type TopLevel = Int 6 | 7 | decodeTopLevel :: ByteString -> Maybe TopLevel 8 | decodeTopLevel = undefined 9 | -------------------------------------------------------------------------------- /test/fixtures/haskell/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /test/fixtures/haskell/package.yaml: -------------------------------------------------------------------------------- 1 | name: haskell 2 | version: 0.0.1 3 | category: Data 4 | dependencies: 5 | - base >= 4.7 && < 5 6 | - aeson 7 | - bytestring 8 | - text 9 | - unordered-containers 10 | - vector 11 | 12 | executables: 13 | haskell: 14 | source-dirs: . 15 | main: Main.hs 16 | -------------------------------------------------------------------------------- /test/fixtures/haskell/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-15.12 2 | packages: 3 | - . 4 | # extra-deps: [] 5 | # flags: {} 6 | # extra-package-dbs: [] 7 | -------------------------------------------------------------------------------- /test/fixtures/haskell/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | size: 494635 10 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/12.yaml 11 | sha256: a71c4293d8f461f455ff0d9815dfe4ab2f1adacd7e0bbc9a218f46ced8c4929a 12 | original: lts-15.12 13 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | QuickTypeTest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.6 6 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/src/main/java/io/quicktype/App.java: -------------------------------------------------------------------------------- 1 | package io.quicktype; 2 | 3 | import java.nio.file.*; 4 | 5 | /** 6 | * Hello world! 7 | * 8 | */ 9 | public class App 10 | { 11 | public static void main( String[] args ) 12 | { 13 | try { 14 | String input = new String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(args[0])), "UTF-8"); 15 | String output = Converter.toJsonString(Converter.fromJsonString(input)); 16 | byte[] arr = output.getBytes("UTF-8"); 17 | System.out.write(arr, 0, arr.length); 18 | } catch (Exception exc) { 19 | System.err.printf("Error: %s\n", exc.getMessage()); 20 | System.exit(1); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/fixtures/java-lombok/src/main/java/io/quicktype/TopLevel.java: -------------------------------------------------------------------------------- 1 | package io.quicktype; 2 | 3 | public class TopLevel { 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/java/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/fixtures/java/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | QuickTypeTest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/fixtures/java/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.6 6 | -------------------------------------------------------------------------------- /test/fixtures/java/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /test/fixtures/java/src/main/java/io/quicktype/App.java: -------------------------------------------------------------------------------- 1 | package io.quicktype; 2 | 3 | import java.nio.file.*; 4 | 5 | /** 6 | * Hello world! 7 | * 8 | */ 9 | public class App 10 | { 11 | public static void main( String[] args ) 12 | { 13 | try { 14 | String input = new String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(args[0])), "UTF-8"); 15 | String output = Converter.toJsonString(Converter.fromJsonString(input)); 16 | byte[] arr = output.getBytes("UTF-8"); 17 | System.out.write(arr, 0, arr.length); 18 | } catch (Exception exc) { 19 | System.err.printf("Error: %s\n", exc.getMessage()); 20 | System.exit(1); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/fixtures/java/src/main/java/io/quicktype/TopLevel.java: -------------------------------------------------------------------------------- 1 | package io.quicktype; 2 | 3 | public class TopLevel { 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/javascript-prop-types/main.js: -------------------------------------------------------------------------------- 1 | import { readFileSync } from "fs"; 2 | import { argv } from "process"; 3 | import { TopLevel } from "./toplevel.js"; 4 | import checkPropTypes from "check-prop-types"; 5 | 6 | const sample = argv[2]; 7 | const json = readFileSync(sample); 8 | const obj = JSON.parse(json); 9 | 10 | const results = checkPropTypes( 11 | { obj: TopLevel }, 12 | { obj }, 13 | "prop", 14 | "MyComponent", 15 | ); 16 | 17 | if (results) { 18 | console.log("Failure:", results); 19 | } else { 20 | console.log("Success"); 21 | } 22 | -------------------------------------------------------------------------------- /test/fixtures/javascript-prop-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript-prop-types", 3 | "version": "0.1.0", 4 | "type": "module", 5 | "description": "Test builds.", 6 | "main": "main.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "Apache-2.0", 12 | "dependencies": { 13 | "check-prop-types": "^1.1.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/javascript/main.js: -------------------------------------------------------------------------------- 1 | const TopLevel = require("./TopLevel"); 2 | 3 | const fs = require("fs"); 4 | const process = require("process"); 5 | 6 | const sample = process.argv[2]; 7 | const json = fs.readFileSync(sample); 8 | 9 | const value = TopLevel.toTopLevel(json); 10 | const backToJson = TopLevel.topLevelToJson(value); 11 | 12 | console.log(backToJson); 13 | -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/.gitignore: -------------------------------------------------------------------------------- 1 | main.jar 2 | TopLevel.kt 3 | -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | kotlinc main.kt TopLevel.kt -include-runtime -cp jackson-annotations-2.9.0.jar:jackson-core-2.9.7.jar:jackson-databind-2.9.7.jar:jackson-module-kotlin-2.9.7.jar -d main.jar 4 | -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/jackson-annotations-2.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/test/fixtures/kotlin-jackson/jackson-annotations-2.9.0.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/jackson-core-2.9.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/test/fixtures/kotlin-jackson/jackson-core-2.9.7.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/jackson-databind-2.9.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/test/fixtures/kotlin-jackson/jackson-databind-2.9.7.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/jackson-module-kotlin-2.9.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/test/fixtures/kotlin-jackson/jackson-module-kotlin-2.9.7.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/main.kt: -------------------------------------------------------------------------------- 1 | package quicktype 2 | 3 | import java.io.File 4 | import java.io.InputStream 5 | 6 | fun output(json: String) { 7 | val bytes = json.toByteArray() 8 | System.out.write(bytes, 0, bytes.size) 9 | } 10 | 11 | fun main(args: Array) { 12 | val json = File(args[0]).readText() 13 | val top = TopLevel.fromJson(json)!! 14 | output(top.toJson()) 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | kotlin -cp jackson-annotations-2.9.0.jar:jackson-core-2.9.7.jar:jackson-databind-2.9.7.jar:jackson-module-kotlin-2.9.7.jar:main.jar quicktype.MainKt "$1" 4 | -------------------------------------------------------------------------------- /test/fixtures/kotlin-jackson/runfixture.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../../../script/quicktype --lang kotlin --framework jackson -t TopLevel -o TopLevel.kt "$1" 4 | ./build.sh 5 | 6 | `./run.sh "$1"` | jq -S -M . > out.json 7 | cat "$1" | jq -S -M . > in.json 8 | 9 | diff in.json out.json 10 | 11 | rm in.json out.json main.jar # TopLevel.kt 12 | -------------------------------------------------------------------------------- /test/fixtures/kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | main.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin/TopLevel.kt: -------------------------------------------------------------------------------- 1 | // To parse the JSON, add this file to your project and do: 2 | // 3 | // val topLevel = TopLevel.fromJson(jsonString) 4 | 5 | import com.beust.klaxon.* 6 | 7 | private val klaxon = 8 | Klaxon() 9 | 10 | data class TopLevel ( 11 | val name: String 12 | ) { 13 | public fun toJson() = klaxon.toJsonString(this as Any) 14 | 15 | companion object { 16 | public fun fromJson(json: String) = klaxon.parse(json) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/kotlin/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | kotlinc main.kt TopLevel.kt -include-runtime -cp klaxon-3.0.1.jar -d main.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin/klaxon-3.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glideapps/quicktype/41950205609abd8c18a8e315ea87d8904f625012/test/fixtures/kotlin/klaxon-3.0.1.jar -------------------------------------------------------------------------------- /test/fixtures/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | package quicktype 2 | 3 | import java.io.File 4 | import java.io.InputStream 5 | 6 | fun output(json: String) { 7 | val bytes = json.toByteArray() 8 | System.out.write(bytes, 0, bytes.size) 9 | } 10 | 11 | fun main(args: Array) { 12 | val json = File("sample.json").readText() 13 | val top = TopLevel.fromJson(json)!! 14 | output(top.toJson()) 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/kotlin/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | kotlin -cp klaxon-3.0.1.jar:main.jar quicktype.MainKt -------------------------------------------------------------------------------- /test/fixtures/kotlin/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "David" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/objective-c/ObjectiveCFixture.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/fixtures/objective-c/ObjectiveCFixture.xcodeproj/xcuserdata/david.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ObjectiveCFixture.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6397CF1A200AE512007A298C 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/fixtures/php/main.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | to(); 11 | $json_string_out = json_encode($json_out); 12 | 13 | echo($json_string_out); 14 | 15 | ?> 16 | -------------------------------------------------------------------------------- /test/fixtures/pike/main.pike: -------------------------------------------------------------------------------- 1 | import .TopLevel; 2 | 3 | int main (int argc, array(string) argv) { 4 | Stdio.File f = Stdio.File(argv[1], "r"); 5 | 6 | mixed json = Standards.JSON.decode(f.read()); 7 | TopLevel tl = TopLevel_from_JSON(json); 8 | string to_json = Standards.JSON.encode(tl, Standards.JSON.HUMAN_READABLE); 9 | 10 | write(to_json); 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /test/fixtures/python/main.py: -------------------------------------------------------------------------------- 1 | import quicktype 2 | import json 3 | import sys 4 | import io 5 | 6 | f = io.open(sys.argv[1], mode="r", encoding="utf-8") 7 | obj = quicktype.top_level_from_dict(json.load(f)) 8 | print(json.dumps(quicktype.top_level_to_dict(obj))) 9 | -------------------------------------------------------------------------------- /test/fixtures/python/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x$QUICKTYPE_PYTHON_VERSION" = "x2.7" ] ; then 4 | PYTHON="python2.7" 5 | else 6 | PYTHON="python3.7" 7 | fi 8 | 9 | "$PYTHON" "$@" 10 | exit $? 11 | -------------------------------------------------------------------------------- /test/fixtures/ruby/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /test/fixtures/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'dry-types' 4 | gem 'dry-struct' 5 | -------------------------------------------------------------------------------- /test/fixtures/ruby/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | concurrent-ruby (1.1.10) 5 | dry-core (1.0.0) 6 | concurrent-ruby (~> 1.0) 7 | zeitwerk (~> 2.6) 8 | dry-inflector (1.0.0) 9 | dry-logic (1.5.0) 10 | concurrent-ruby (~> 1.0) 11 | dry-core (~> 1.0, < 2) 12 | zeitwerk (~> 2.6) 13 | dry-struct (1.6.0) 14 | dry-core (~> 1.0, < 2) 15 | dry-types (>= 1.7, < 2) 16 | ice_nine (~> 0.11) 17 | zeitwerk (~> 2.6) 18 | dry-types (1.7.0) 19 | concurrent-ruby (~> 1.0) 20 | dry-core (~> 1.0, < 2) 21 | dry-inflector (~> 1.0, < 2) 22 | dry-logic (>= 1.4, < 2) 23 | zeitwerk (~> 2.6) 24 | ice_nine (0.11.2) 25 | zeitwerk (2.6.6) 26 | 27 | PLATFORMS 28 | arm64-darwin-22 29 | 30 | DEPENDENCIES 31 | dry-struct 32 | dry-types 33 | 34 | BUNDLED WITH 35 | 2.4.2 36 | -------------------------------------------------------------------------------- /test/fixtures/ruby/main.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | module QuickType 4 | require 'json' 5 | require './TopLevel.rb' 6 | 7 | json = File.read(ARGV[0]) 8 | top = TopLevel.from_json! json 9 | 10 | puts top.to_json 11 | end -------------------------------------------------------------------------------- /test/fixtures/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "quick_type_test" 3 | version = "0.0.1" 4 | 5 | [[bin]] 6 | name = "quick_type_test" 7 | path = "main.rs" 8 | test = false 9 | doc = false 10 | 11 | [dependencies] 12 | serde_json = "1.0" 13 | serde = "1.0" 14 | serde_derive = "1.0" 15 | 16 | # The development profile, used for `cargo build` 17 | [profile.dev] 18 | codegen-units = 1 # Controls whether the compiler passes `-C codegen-units` -------------------------------------------------------------------------------- /test/fixtures/rust/main.rs: -------------------------------------------------------------------------------- 1 | mod module_under_test; 2 | 3 | extern crate serde; 4 | 5 | #[macro_use] 6 | extern crate serde_derive; 7 | 8 | extern crate serde_json; 9 | 10 | use module_under_test::TopLevel; 11 | use std::env; 12 | use std::fs::File; 13 | use std::io::prelude::*; 14 | 15 | fn main() { 16 | 17 | let args: Vec = env::args().collect(); 18 | let filename = &args[1]; 19 | 20 | let mut f = File::open(filename).expect("Input file not found"); 21 | 22 | let mut json = String::new(); 23 | f.read_to_string(&mut json) 24 | .expect("Input file cannot be read."); 25 | 26 | let top_level: TopLevel = serde_json::from_str(&json).unwrap(); 27 | 28 | let result = serde_json::to_string(&top_level).unwrap(); 29 | 30 | println!("{}", &result); 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/scala3/.gitignore: -------------------------------------------------------------------------------- 1 | main.jar 2 | .bsp 3 | .scala-build -------------------------------------------------------------------------------- /test/fixtures/scala3/circe.scala: -------------------------------------------------------------------------------- 1 | //> using scala "3.2.1" 2 | //> using lib "io.circe::circe-core:0.15.0-M1" 3 | //> using lib "io.circe::circe-parser:0.15.0-M1" 4 | //> using options "-Xmax-inlines", "3000" 5 | package quicktype 6 | 7 | import io.circe._ 8 | import io.circe.parser._ 9 | import io.circe.syntax._ 10 | /* 11 | 12 | case class TopLevel ( 13 | val data : Long, 14 | val next : Option[TopLevel] = None 15 | ) derives Encoder.AsObject, Decoder */ 16 | 17 | 18 | @main def main = 19 | val json = scala.io.Source.fromFile("sample.json").getLines.mkString 20 | 21 | parse(json).map(x => 22 | val arg = x.as[TopLevel] 23 | arg match { 24 | case Right(y) => 25 | val jsonString = y.asJson 26 | val arr : Array[Byte] = jsonString.toString.getBytes("UTF-8") 27 | System.out.write(arr, 0, arr.length) 28 | case Left(y) => println(y); println("-----");println(y.getMessage) 29 | } 30 | ) 31 | -------------------------------------------------------------------------------- /test/fixtures/scala3/rename/debug.scala: -------------------------------------------------------------------------------- 1 | //> using scala "3.1.1" 2 | //> using lib "com.lihaoyi::upickle:1.6.0" 3 | 4 | 5 | 6 | 7 | /* case class TopLevel (val name: String) 8 | 9 | given re : ReadWriter[TopLevel] = macroRW 10 | */ 11 | @main def main = 12 | val json = scala.io.Source.fromFile("/Users/simon/Code/quicktype/test/inputs/json/samples/github-events.json").getLines.mkString 13 | val output = ujson.read(json) 14 | val arr : Array[Byte] = ujson.write(output).getBytes("UTF-8"); 15 | System.out.write(arr, 0, arr.length); 16 | 17 | -------------------------------------------------------------------------------- /test/fixtures/scala3/rename/upickle.scala: -------------------------------------------------------------------------------- 1 | //> using scala "3.1.1" 2 | //> using lib "com.lihaoyi::upickle:1.6.0" 3 | 4 | 5 | 6 | 7 | 8 | object OptionPickler extends upickle.AttributeTagged { 9 | 10 | import upickle.default.Writer 11 | import upickle.default.Reader 12 | override implicit def OptionWriter[T: Writer]: Writer[Option[T]] = 13 | implicitly[Writer[T]].comap[Option[T]] { 14 | case None => null.asInstanceOf[T] 15 | case Some(x) => x 16 | } 17 | 18 | override implicit def OptionReader[T: Reader]: Reader[Option[T]] = { 19 | new Reader.Delegate[Any, Option[T]](implicitly[Reader[T]].map(Some(_))){ 20 | override def visitNull(index: Int) = None 21 | } 22 | } 23 | } 24 | 25 | @main def main = 26 | import quicktype.OptionPickler._ 27 | val json = scala.io.Source.fromFile("sample.json").getLines.mkString 28 | //implicit val rw : ReadWriter[quicktype.TopLevel] = macroRW 29 | val output = read[TopLevel](json) 30 | val arr : Array[Byte] = write(output).getBytes("UTF-8"); 31 | System.out.write(arr, 0, arr.length); 32 | 33 | -------------------------------------------------------------------------------- /test/fixtures/scala3/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | scala-cli circe.scala TopLevel.scala 4 | -------------------------------------------------------------------------------- /test/fixtures/swift/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.xcuserdatad 3 | -------------------------------------------------------------------------------- /test/fixtures/swift/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | let filename = CommandLine.arguments[1] 4 | 5 | guard let data = FileHandle(forReadingAtPath: filename)?.readDataToEndOfFile() else { 6 | print("Error: Could not read input file") 7 | exit(1) 8 | } 9 | 10 | let obj = try TopLevel(data: data) 11 | 12 | guard let jsonString = try obj.jsonString() else { 13 | print("Error: Could not serialize") 14 | exit(1) 15 | } 16 | 17 | print(jsonString) 18 | 19 | -------------------------------------------------------------------------------- /test/fixtures/typescript-effect-schema/main.ts: -------------------------------------------------------------------------------- 1 | import * as TopLevel from "./TopLevel"; 2 | import fs from "fs"; 3 | import process from "process"; 4 | import * as Schema from "effect/Schema"; 5 | 6 | const sample = process.argv[2]; 7 | const json = fs.readFileSync(sample); 8 | 9 | const value = JSON.parse(json.toString()); 10 | let schema = TopLevel.TopLevel ?? TopLevel.TopLevelElement; 11 | if (!schema) { 12 | // Sometimes key is prefixed with funPrefixes (e.g. 2df80.json) 13 | Object.keys(TopLevel).some((key) => { 14 | if (key.endsWith("TopLevel") || key.endsWith("TopLevelElement")) { 15 | schema = TopLevel[key]; 16 | return true; 17 | } 18 | }); 19 | } 20 | 21 | if (!schema) { 22 | throw new Error("No schema found"); 23 | } 24 | 25 | let backToJson: string; 26 | if (Array.isArray(value)) { 27 | const parsedValue = value.map((v) => { 28 | return Schema.decodeUnknownSync(schema)(v); 29 | }); 30 | backToJson = JSON.stringify(parsedValue, null, 2); 31 | } else { 32 | const parsedValue = Schema.decodeUnknownSync(schema)(value); 33 | backToJson = JSON.stringify(parsedValue, null, 2); 34 | } 35 | 36 | console.log(backToJson); 37 | -------------------------------------------------------------------------------- /test/fixtures/typescript-effect-schema/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-effect-schema", 3 | "version": "0.1.0", 4 | "type": "module", 5 | "description": "Test builds.", 6 | "scripts": { 7 | "test": "tsx main.ts" 8 | }, 9 | "author": "", 10 | "license": "Apache-2.0", 11 | "devDependencies": { 12 | "tsx": "^3.12.2", 13 | "typescript": "^5.4.0" 14 | }, 15 | "dependencies": { 16 | "effect": "^3.10.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/typescript-effect-schema/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6" 4 | }, 5 | "files": ["*.ts"] 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/typescript-zod/main.ts: -------------------------------------------------------------------------------- 1 | import * as TopLevel from "./TopLevel"; 2 | import fs from "fs"; 3 | import process from "process"; 4 | 5 | const sample = process.argv[2]; 6 | const json = fs.readFileSync(sample); 7 | 8 | const value = JSON.parse(json.toString()); 9 | let schema = TopLevel.TopLevelSchema ?? TopLevel.TopLevelElementSchema; 10 | if (!schema) { 11 | // Sometimes key is prefixed with funPrefixes (e.g. 2df80.json) 12 | Object.keys(TopLevel).some((key) => { 13 | if ( 14 | key.endsWith("TopLevelSchema") || 15 | key.endsWith("TopLevelElementSchema") 16 | ) { 17 | schema = TopLevel[key]; 18 | return true; 19 | } 20 | }); 21 | } 22 | 23 | if (!schema) { 24 | throw new Error("No schema found"); 25 | } 26 | 27 | let backToJson: string; 28 | if (Array.isArray(value)) { 29 | const parsedValue = value.map((v) => schema.parse(v)); 30 | backToJson = JSON.stringify(parsedValue, null, 2); 31 | } else { 32 | const parsedValue = schema.parse(value); 33 | backToJson = JSON.stringify(parsedValue, null, 2); 34 | } 35 | 36 | console.log(backToJson); 37 | -------------------------------------------------------------------------------- /test/fixtures/typescript-zod/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-zod", 3 | "version": "0.1.0", 4 | "type": "module", 5 | "description": "Test builds.", 6 | "scripts": { 7 | "test": "tsx main.ts" 8 | }, 9 | "author": "", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "zod": "^3.6.1" 13 | }, 14 | "devDependencies": { 15 | "tsx": "^3.12.2", 16 | "typescript": "^4.3.5" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/typescript-zod/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6" 4 | }, 5 | "files": ["*.ts"] 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/typescript/main.ts: -------------------------------------------------------------------------------- 1 | import * as TopLevel from "./TopLevel"; 2 | 3 | declare function require(path: string): any; 4 | const fs = require("fs"); 5 | const process = require("process"); 6 | 7 | const sample = process.argv[2]; 8 | const json = fs.readFileSync(sample); 9 | 10 | const value = TopLevel.Convert.toTopLevel(json); 11 | const backToJson = TopLevel.Convert.topLevelToJson(value); 12 | 13 | console.log(backToJson); 14 | -------------------------------------------------------------------------------- /test/fixtures/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6" 4 | }, 5 | "files": ["*.ts"] 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/graphql/github1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "login": "schani", 5 | "realName": "Mark Probst" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/inputs/graphql/github1.graphql: -------------------------------------------------------------------------------- 1 | query { 2 | viewer { 3 | login 4 | realName: name 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/graphql/github2.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "login": "schani", 5 | "repositories": { 6 | "totalCount": 99, 7 | "nodes": [ 8 | { 9 | "name": "flickr-clojure" 10 | }, 11 | { 12 | "name": "rwimg" 13 | }, 14 | { 15 | "name": "lispreader" 16 | }, 17 | { 18 | "name": "metapixel" 19 | }, 20 | { 21 | "name": "lisp-utils" 22 | }, 23 | { 24 | "name": "mathmap" 25 | }, 26 | { 27 | "name": "bintrans" 28 | }, 29 | { 30 | "name": "icfp-2004" 31 | }, 32 | { 33 | "name": "icfp-2002" 34 | }, 35 | { 36 | "name": "icfp-2008" 37 | } 38 | ] 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/inputs/graphql/github2.graphql: -------------------------------------------------------------------------------- 1 | query { 2 | viewer { 3 | login 4 | repositories(first: 10) { 5 | totalCount 6 | nodes { 7 | name 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/graphql/github3.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "login": "schani", 5 | "repository": { 6 | "pullRequests": { 7 | "nodes": [ 8 | { 9 | "state": "MERGED" 10 | }, 11 | { 12 | "state": "MERGED" 13 | }, 14 | { 15 | "state": "MERGED" 16 | }, 17 | { 18 | "state": "OPEN" 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/inputs/graphql/github3.graphql: -------------------------------------------------------------------------------- 1 | query { 2 | viewer { 3 | login 4 | repository(name: "metapixel") { 5 | pullRequests(first:10) { 6 | nodes { 7 | state 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/inputs/graphql/github4.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "repository": { 5 | "pullRequests": { 6 | "nodes": [ 7 | { 8 | "state": "MERGED" 9 | }, 10 | { 11 | "state": "MERGED" 12 | }, 13 | { 14 | "state": "MERGED" 15 | }, 16 | { 17 | "state": "OPEN" 18 | } 19 | ] 20 | } 21 | }, 22 | "login": "schani", 23 | "name": "Mark Probst" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/inputs/graphql/github4.graphql: -------------------------------------------------------------------------------- 1 | query { 2 | viewer { 3 | ... UserFragment 4 | repository(name: "metapixel") { 5 | pullRequests(first:10) { 6 | nodes { 7 | state 8 | } 9 | } 10 | } 11 | } 12 | } 13 | 14 | fragment UserFragment on User { 15 | login 16 | name 17 | } 18 | -------------------------------------------------------------------------------- /test/inputs/graphql/github5.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "login": "schani", 5 | "name": "Mark Probst" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/inputs/graphql/github5.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "viewer": { 4 | "login": "schani" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/graphql/github5.graphql: -------------------------------------------------------------------------------- 1 | query test($more: Boolean!) { 2 | viewer { 3 | login 4 | name @include(if: $more) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/graphql/github6.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "resource": { 4 | "url": "https://github.com/quicktype/quicktype" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/graphql/github6.graphql: -------------------------------------------------------------------------------- 1 | query { 2 | resource(url: "https://github.com/quicktype/quicktype") { 3 | url 4 | ... on User { 5 | login 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/inputs/graphql/github7.graphql: -------------------------------------------------------------------------------- 1 | { 2 | viewer { 3 | login 4 | starredRepositories { 5 | totalCount 6 | } 7 | repositories(first: 3) { 8 | edges { 9 | node { 10 | name 11 | stargazers { 12 | totalCount 13 | } 14 | forks { 15 | totalCount 16 | } 17 | watchers { 18 | totalCount 19 | } 20 | issues(states:[OPEN]) { 21 | totalCount 22 | } 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/inputs/graphql/github8.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "repository": { 4 | "nameWithOwner": "quicktype/quicktype", 5 | "n303": { 6 | "title": "Don't process.exit on error when running tests", 7 | "state": "OPEN" 8 | }, 9 | "n307": { 10 | "title": "DO NOT MERGE: GraphQL", 11 | "merged": false 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/inputs/graphql/github8.graphql: -------------------------------------------------------------------------------- 1 | { 2 | repository(owner: "quicktype", name: "quicktype") { 3 | nameWithOwner, 4 | n303: issueOrPullRequest(number: 303) { 5 | ... IOPR 6 | }, 7 | n307: issueOrPullRequest(number: 307) { 8 | ... IOPR 9 | } 10 | } 11 | } 12 | 13 | fragment IOPR on IssueOrPullRequest { 14 | ... on Issue { 15 | title 16 | state 17 | } 18 | ... on PullRequest { 19 | title 20 | merged 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/inputs/graphql/github9.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "addReaction": { 4 | "clientMutationId": "string", 5 | "reaction": { 6 | "content": "THUMBS_UP" 7 | }, 8 | "subject": { 9 | "reactionGroups": [ 10 | { 11 | "content":"THUMBS_UP" 12 | }, 13 | { 14 | "content":"THUMBS_DOWN" 15 | }, 16 | { 17 | "content":"LAUGH" 18 | }, 19 | { 20 | "content":"HOORAY" 21 | }, 22 | { 23 | "content":"CONFUSED" 24 | }, 25 | { 26 | "content":"HEART" 27 | } 28 | ], 29 | "viewerCanReact": true 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/inputs/graphql/github9.graphql: -------------------------------------------------------------------------------- 1 | mutation AddReaction($input: AddReactionInput!){ 2 | addReaction(input: $input){ 3 | clientMutationId 4 | reaction { 5 | content 6 | } 7 | subject { 8 | viewerCanReact 9 | reactionGroups { 10 | content 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /test/inputs/json/misc/016af.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 126018099}, {"date": "2017-07-30", "population": 126017291}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/033b1.json: -------------------------------------------------------------------------------- 1 | {"base":"EUR","date":"2000-01-03","rates":{"AUD":1.5346,"CAD":1.4577,"CHF":1.6043,"CYP":0.5767,"CZK":36.063,"DKK":7.4404,"EEK":15.647,"GBP":0.6246,"HKD":7.8624,"HUF":254.53,"ISK":73.03,"JPY":102.75,"KRW":1140.0,"LTL":4.0454,"LVL":0.5916,"MTL":0.4151,"NOK":8.062,"NZD":1.9331,"PLN":4.1835,"ROL":18273.0,"SEK":8.552,"SGD":1.6769,"SIT":198.89,"SKK":42.317,"TRL":546130.0,"USD":1.009,"ZAR":6.2013}} -------------------------------------------------------------------------------- /test/inputs/json/misc/07540.json: -------------------------------------------------------------------------------- 1 | { 2 | "cookies": {} 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/json/misc/0779f.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"CLE","state":"Ohio","name":"Cleveland Hopkins International","weather":{"visibility":10.00,"weather":"Partly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"6:51 PM Local","url":"http://weather.gov/"},"temp":"78.0 F (25.6 C)","wind":"Northeast at 10.4mph"},"ICAO":"KCLE","city":"Cleveland","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/07c75.json: -------------------------------------------------------------------------------- 1 | [{"id":"APL-1.0","identifiers":[{"identifier":"APL-1.0","scheme":"SPDX"}],"links":[{"note":"OSI Page","url":"https://opensource.org/licenses/APL-1.0"}],"name":"Adaptive Public License, Version 1.0","other_names":[],"superseded_by":null,"keywords":["osi-approved","miscellaneous"],"text":[{"media_type":"text/html","title":"HTML","url":"https://opensource.org/licenses/APL-1.0"}]},{"id":"Artistic-2.0","identifiers":[{"identifier":"Artistic-2.0","scheme":"DEP5"},{"identifier":"Artistic-2.0","scheme":"SPDX"},{"identifier":"License :: OSI Approved :: Artistic License","scheme":"Trove"}],"links":[{"note":"OSI Page","url":"https://opensource.org/licenses/Artistic-2.0"}],"name":"Artistic License, Version 2.0","other_names":[],"superseded_by":null,"keywords":["miscellaneous","osi-approved"],"text":[{"media_type":"text/html","title":"HTML","url":"https://opensource.org/licenses/Artistic-2.0"}]},{"id":"OSL-3.0","identifiers":[{"identifier":"OSL-3.0","scheme":"SPDX"}],"links":[{"note":"OSI Page","url":"https://opensource.org/licenses/OSL-3.0"}],"name":"Open Software License, Version 3.0","other_names":[],"superseded_by":null,"keywords":["osi-approved","miscellaneous"],"text":[{"media_type":"text/html","title":"HTML","url":"https://opensource.org/licenses/OSL-3.0"}]}] 2 | -------------------------------------------------------------------------------- /test/inputs/json/misc/112b5.json: -------------------------------------------------------------------------------- 1 | { 2 | "args": {}, 3 | "headers": { 4 | "Accept-Encoding": "identity", 5 | "Connection": "close", 6 | "Host": "httpbin.org", 7 | "User-Agent": "Python-urllib/3.6" 8 | }, 9 | "origin": "209.58.130.210", 10 | "url": "http://httpbin.org/cache/60" 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/json/misc/13d8d.json: -------------------------------------------------------------------------------- 1 | [{"category":"violent-crime","location_type":"Force","location":{"latitude":"52.629909","street":{"id":883345,"name":"On or near Marquis Street"},"longitude":"-1.132073"},"context":"","outcome_status":{"category":"Status update unavailable","date":"2015-06"},"persistent_id":"e1ef17934e37a490f0cb67ff6d1d0fa9cd40959081f05255127e99c6334d18d8","id":39352006,"location_subtype":"","month":"2015-02"}] -------------------------------------------------------------------------------- /test/inputs/json/misc/14d38.json: -------------------------------------------------------------------------------- 1 | { 2 | "headers": { 3 | "Accept-Encoding": "identity", 4 | "Connection": "close", 5 | "Host": "httpbin.org", 6 | "User-Agent": "Python-urllib/3.6" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/inputs/json/misc/167d6.json: -------------------------------------------------------------------------------- 1 | {"base":"HKD","date":"2017-07-28","rates":{"AUD":0.16081,"BGN":0.21348,"BRL":0.40404,"CAD":0.16059,"CHF":0.12397,"CNY":0.86327,"CZK":2.8433,"DKK":0.81172,"GBP":0.097768,"HRK":0.80906,"HUF":33.285,"IDR":1707.1,"ILS":0.45589,"INR":8.2146,"JPY":14.231,"KRW":143.82,"MXN":2.2714,"MYR":0.54827,"NOK":1.0173,"NZD":0.17131,"PHP":6.4627,"PLN":0.46383,"RON":0.49753,"RUB":7.6225,"SEK":1.0408,"SGD":0.17407,"THB":4.273,"TRY":0.45258,"USD":0.12803,"ZAR":1.668,"EUR":0.10915}} -------------------------------------------------------------------------------- /test/inputs/json/misc/1b28c.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 130342684}, {"date": "2017-07-30", "population": 130347004}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/24f52.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"LAX","state":"California","name":"Los Angeles International","weather":{"visibility":10.00,"weather":"A Few Clouds","meta":{"credit":"NOAA's National Weather Service","updated":"3:53 PM Local","url":"http://weather.gov/"},"temp":"76.0 F (24.4 C)","wind":"West at 16.1mph"},"ICAO":"KLAX","city":"Los Angeles","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/3659d.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 48560350}, {"date": "2017-07-30", "population": 48563702}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/36d5d.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"PHX","state":"Arizona","name":"Phoenix Sky Harbor International","weather":{"visibility":10.00,"weather":"Mostly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"3:51 PM Local","url":"http://weather.gov/"},"temp":"101.0 F (38.3 C)","wind":"Northwest at 9.2mph"},"ICAO":"KPHX","city":"Phoenix","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/3a6b3.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"ORD","state":"Illinois","name":"Chicago OHare International","weather":{"visibility":10.00,"weather":"A Few Clouds","meta":{"credit":"NOAA's National Weather Service","updated":"5:51 PM Local","url":"http://weather.gov/"},"temp":"78.0 F (25.6 C)","wind":"East at 9.2mph"},"ICAO":"KORD","city":"Chicago","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/43eaf.json: -------------------------------------------------------------------------------- 1 | {"base":"EUR","date":"2017-07-28","rates":{"AUD":1.4732,"BGN":1.9558,"BRL":3.7015,"CAD":1.4712,"CHF":1.1357,"CNY":7.9087,"CZK":26.048,"DKK":7.4364,"GBP":0.89568,"HKD":9.1613,"HRK":7.412,"HUF":304.93,"IDR":15639.0,"ILS":4.1765,"INR":75.256,"JPY":130.37,"KRW":1317.6,"MXN":20.809,"MYR":5.0229,"NOK":9.3195,"NZD":1.5694,"PHP":59.207,"PLN":4.2493,"RON":4.558,"RUB":69.832,"SEK":9.5355,"SGD":1.5947,"THB":39.146,"TRY":4.1462,"USD":1.1729,"ZAR":15.281}} -------------------------------------------------------------------------------- /test/inputs/json/misc/4961a.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 7521545060}, {"date": "2017-07-30", "population": 7521770406}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/4a0d7.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 326651270}, {"date": "2017-07-30", "population": 326657725}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/4e336.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 59795773}, {"date": "2017-07-30", "population": 59795755}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/54147.json: -------------------------------------------------------------------------------- 1 | { 2 | "args": {}, 3 | "data": "", 4 | "files": {}, 5 | "form": {}, 6 | "headers": { 7 | "Accept-Encoding": "identity", 8 | "Connection": "close", 9 | "Host": "httpbin.org", 10 | "User-Agent": "Python-urllib/3.6" 11 | }, 12 | "origin": "209.58.130.210", 13 | "url": "http://httpbin.org/delay/3" 14 | } 15 | -------------------------------------------------------------------------------- /test/inputs/json/misc/5dd0d.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"AUS","state":"Texas","name":"Austin-Bergstrom International","weather":{"visibility":10.00,"weather":"Mostly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"5:53 PM Local","url":"http://weather.gov/"},"temp":"105.0 F (40.6 C)","wind":""},"ICAO":"KAUS","city":"Austin","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/5eb20.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"BOS","state":"Massachusetts","name":"General Edward Lawrence Logan International","weather":{"visibility":10.00,"weather":"Mostly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"6:54 PM Local","url":"http://weather.gov/"},"temp":"66.0 F (18.9 C)","wind":"Northeast at 15.0mph"},"ICAO":"KBOS","city":"Boston","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/5f3a1.json: -------------------------------------------------------------------------------- 1 | {"base":"USD","date":"2017-07-28","rates":{"AUD":1.256,"BGN":1.6675,"BRL":3.1559,"CAD":1.2543,"CHF":0.96828,"CNY":6.7429,"CZK":22.208,"DKK":6.3402,"GBP":0.76365,"HKD":7.8108,"HRK":6.3194,"HUF":259.98,"IDR":13334.0,"ILS":3.5608,"INR":64.162,"JPY":111.15,"KRW":1123.4,"MXN":17.741,"MYR":4.2825,"NOK":7.9457,"NZD":1.3381,"PHP":50.479,"PLN":3.6229,"RON":3.8861,"RUB":59.538,"SEK":8.1298,"SGD":1.3596,"THB":33.375,"TRY":3.535,"ZAR":13.028,"EUR":0.85259}} -------------------------------------------------------------------------------- /test/inputs/json/misc/61b66.json: -------------------------------------------------------------------------------- 1 | {"delay":"true","IATA":"JFK","state":"New York","name":"John F Kennedy International","weather":{"visibility":10.00,"weather":"Mostly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"6:51 PM Local","url":"http://weather.gov/"},"temp":"75.0 F (23.9 C)","wind":"North at 13.8mph"},"ICAO":"KJFK","city":"New York","status":{"reason":"WEATHER / WIND","closureBegin":"","endTime":"","minDelay":"","avgDelay":"51 minutes","maxDelay":"","closureEnd":"","trend":"","type":"Ground Delay"}} -------------------------------------------------------------------------------- /test/inputs/json/misc/6260a.json: -------------------------------------------------------------------------------- 1 | {"base":"JPY","date":"2017-07-28","rates":{"AUD":0.0113,"BGN":0.015002,"BRL":0.028392,"CAD":0.011285,"CHF":0.0087114,"CNY":0.060663,"CZK":0.1998,"DKK":0.057041,"GBP":0.0068703,"HKD":0.070272,"HRK":0.056854,"HUF":2.339,"IDR":119.96,"ILS":0.032036,"INR":0.57725,"KRW":10.107,"MXN":0.15961,"MYR":0.038528,"NOK":0.071485,"NZD":0.012038,"PHP":0.45415,"PLN":0.032594,"RON":0.034962,"RUB":0.53564,"SEK":0.073142,"SGD":0.012232,"THB":0.30027,"TRY":0.031803,"USD":0.0089967,"ZAR":0.11721,"EUR":0.0076705}} -------------------------------------------------------------------------------- /test/inputs/json/misc/6617c.json: -------------------------------------------------------------------------------- 1 | {"message": "success", "timestamp": 1501371025, "iss_position": {"latitude": "-40.0662", "longitude": "-157.1740"}} -------------------------------------------------------------------------------- /test/inputs/json/misc/67c03.json: -------------------------------------------------------------------------------- 1 | {"message": "success", "people": [{"name": "Peggy Whitson", "craft": "ISS"}, {"name": "Fyodor Yurchikhin", "craft": "ISS"}, {"name": "Jack Fischer", "craft": "ISS"}, {"name": "Sergey Ryazanskiy", "craft": "ISS"}, {"name": "Randy Bresnik", "craft": "ISS"}, {"name": "Paolo Nespoli", "craft": "ISS"}], "number": 6} -------------------------------------------------------------------------------- /test/inputs/json/misc/70c77.json: -------------------------------------------------------------------------------- 1 | {"base":"HUF","date":"2017-07-28","rates":{"AUD":0.0048313,"BGN":0.0064139,"BRL":0.012139,"CAD":0.0048247,"CHF":0.0037245,"CNY":0.025936,"CZK":0.085423,"DKK":0.024387,"GBP":0.0029373,"HKD":0.030044,"HRK":0.024307,"IDR":51.287,"ILS":0.013697,"INR":0.2468,"JPY":0.42754,"KRW":4.321,"MXN":0.068242,"MYR":0.016472,"NOK":0.030563,"NZD":0.0051468,"PHP":0.19417,"PLN":0.013935,"RON":0.014948,"RUB":0.22901,"SEK":0.031271,"SGD":0.0052297,"THB":0.12838,"TRY":0.013597,"USD":0.0038465,"ZAR":0.050113,"EUR":0.0032794}} -------------------------------------------------------------------------------- /test/inputs/json/misc/75912.json: -------------------------------------------------------------------------------- 1 | {"base":"ZAR","date":"2017-07-28","rates":{"AUD":0.096407,"BGN":0.12799,"BRL":0.24223,"CAD":0.096276,"CHF":0.074321,"CNY":0.51755,"CZK":1.7046,"DKK":0.48664,"GBP":0.058614,"HKD":0.59952,"HRK":0.48505,"HUF":19.955,"IDR":1023.4,"ILS":0.27331,"INR":4.9248,"JPY":8.5315,"KRW":86.225,"MXN":1.3618,"MYR":0.3287,"NOK":0.60988,"NZD":0.1027,"PHP":3.8746,"PLN":0.27808,"RON":0.29828,"RUB":4.5699,"SEK":0.62401,"SGD":0.10436,"THB":2.5617,"TRY":0.27133,"USD":0.076755,"EUR":0.065441}} -------------------------------------------------------------------------------- /test/inputs/json/misc/7d722.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"SFO","state":"California","name":"San Francisco International","weather":{"visibility":10.00,"weather":"A Few Clouds and Breezy","meta":{"credit":"NOAA's National Weather Service","updated":"3:56 PM Local","url":"http://weather.gov/"},"temp":"65.0 F (18.3 C)","wind":"Northwest at 21.9mph"},"ICAO":"KSFO","city":"San Francisco","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/7df41.json: -------------------------------------------------------------------------------- 1 | {"pc":{"label":"PC","count":11361,"peak24":17053},"ps3":{"label":"PS3","count":9614,"peak24":11067},"xbox":{"label":"XBOX360","count":2267,"peak24":2544},"xone":{"label":"XBOXONE","count":17395,"peak24":18728},"ps4":{"label":"PS4","count":19403,"peak24":22103}} -------------------------------------------------------------------------------- /test/inputs/json/misc/7dfa6.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 80629539}, {"date": "2017-07-30", "population": 80629361}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/82509.json: -------------------------------------------------------------------------------- 1 | { 2 | "origin": "209.58.130.210" 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/json/misc/8a62c.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 10890992}, {"date": "2017-07-30", "population": 10890930}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/9617f.json: -------------------------------------------------------------------------------- 1 | {"base":"HRK","date":"2017-07-28","rates":{"AUD":0.19876,"BGN":0.26387,"BRL":0.49939,"CAD":0.19849,"CHF":0.15322,"CNY":1.067,"CZK":3.5143,"DKK":1.0033,"GBP":0.12084,"HKD":1.236,"HUF":41.14,"IDR":2110.0,"ILS":0.56348,"INR":10.153,"JPY":17.589,"KRW":177.77,"MXN":2.8075,"MYR":0.67767,"NOK":1.2574,"NZD":0.21174,"PHP":7.988,"PLN":0.5733,"RON":0.61495,"RUB":9.4215,"SEK":1.2865,"SGD":0.21515,"THB":5.2814,"TRY":0.55939,"USD":0.15824,"ZAR":2.0617,"EUR":0.13492}} -------------------------------------------------------------------------------- /test/inputs/json/misc/96f7c.json: -------------------------------------------------------------------------------- 1 | {"verifiable_password_authentication":true,"github_services_sha":"885b7c6bf25b648275ad18b24714b8f11bb3c625","hooks":["192.30.252.0/22"],"git":["192.30.252.0/22"],"pages":["192.30.252.153/32","192.30.252.154/32"],"importer":["54.87.5.173","54.166.52.62","23.20.92.3"]} -------------------------------------------------------------------------------- /test/inputs/json/misc/a71df.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"ATL","state":"Georgia","name":"Hartsfield-Jackson Atlanta International","weather":{"visibility":10.00,"weather":"A Few Clouds","meta":{"credit":"NOAA's National Weather Service","updated":"6:52 PM Local","url":"http://weather.gov/"},"temp":"86.0 F (30.0 C)","wind":"Northwest at 12.7mph"},"ICAO":"KATL","city":"Atlanta","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/a9691.json: -------------------------------------------------------------------------------- 1 | {"base":"GBP","date":"2017-07-28","rates":{"AUD":1.6448,"BGN":2.1836,"BRL":4.1326,"CAD":1.6426,"CHF":1.268,"CNY":8.8298,"CZK":29.082,"DKK":8.3025,"HKD":10.228,"HRK":8.2753,"HUF":340.45,"IDR":17460.0,"ILS":4.6629,"INR":84.021,"JPY":145.55,"KRW":1471.1,"MXN":23.233,"MYR":5.6079,"NOK":10.405,"NZD":1.7522,"PHP":66.103,"PLN":4.7442,"RON":5.0889,"RUB":77.965,"SEK":10.646,"SGD":1.7804,"THB":43.705,"TRY":4.6291,"USD":1.3095,"ZAR":17.061,"EUR":1.1165}} -------------------------------------------------------------------------------- /test/inputs/json/misc/abb4b.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 1343714342}, {"date": "2017-07-30", "population": 1343757282}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/ac944.json: -------------------------------------------------------------------------------- 1 | {"base":"EUR","date":"2017-07-28","rates":{"AUD":1.4732,"BGN":1.9558,"BRL":3.7015,"CAD":1.4712,"CHF":1.1357,"CNY":7.9087,"CZK":26.048,"DKK":7.4364,"GBP":0.89568,"HKD":9.1613,"HRK":7.412,"HUF":304.93,"IDR":15639.0,"ILS":4.1765,"INR":75.256,"JPY":130.37,"KRW":1317.6,"MXN":20.809,"MYR":5.0229,"NOK":9.3195,"NZD":1.5694,"PHP":59.207,"PLN":4.2493,"RON":4.558,"RUB":69.832,"SEK":9.5355,"SGD":1.5947,"THB":39.146,"TRY":4.1462,"USD":1.1729,"ZAR":15.281}} -------------------------------------------------------------------------------- /test/inputs/json/misc/b6f2c.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 38556444}, {"date": "2017-07-30", "population": 38556351}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/b6fe5.json: -------------------------------------------------------------------------------- 1 | {"movie":"http://showtimes.everyday.in.th/api/v2/movie/","movie-image":"http://showtimes.everyday.in.th/api/private/movie/image/","group":"http://showtimes.everyday.in.th/api/v2/group/","theater":"http://showtimes.everyday.in.th/api/v2/theater/"} -------------------------------------------------------------------------------- /test/inputs/json/misc/b9f64.json: -------------------------------------------------------------------------------- 1 | { 2 | "user-agent": "Python-urllib/3.6" 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/json/misc/bb1ec.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 64957801}, {"date": "2017-07-30", "population": 64958539}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/c0a3a.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"MIA","state":"Florida","name":"Miami International","weather":{"visibility":10.00,"weather":"Partly Cloudy","meta":{"credit":"NOAA's National Weather Service","updated":"6:53 PM Local","url":"http://weather.gov/"},"temp":"87.0 F (30.6 C)","wind":"West at 8.1mph"},"ICAO":"KMIA","city":"Miami","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/ccd18.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"SJC","state":"California","name":"San Jose International","weather":{"visibility":10.00,"weather":"Fair","meta":{"credit":"NOAA's National Weather Service","updated":"3:53 PM Local","url":"http://weather.gov/"},"temp":"77.0 F (25.0 C)","wind":"Northwest at 13.8mph"},"ICAO":"KSJC","city":"San Jose","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/cd238.json: -------------------------------------------------------------------------------- 1 | {"delay":"false","IATA":"PDX","state":"Oregon","name":"Portland International","weather":{"visibility":10.00,"weather":"Fair","meta":{"credit":"NOAA's National Weather Service","updated":"3:53 PM Local","url":"http://weather.gov/"},"temp":"86.0 F (30.0 C)","wind":"Northwest at 10.4mph"},"ICAO":"KPDX","city":"Portland","status":{"reason":"No known delays for this airport.","closureBegin":"","endTime":"","minDelay":"","avgDelay":"","maxDelay":"","closureEnd":"","trend":"","type":""}} -------------------------------------------------------------------------------- /test/inputs/json/misc/cd463.json: -------------------------------------------------------------------------------- 1 | {"base":"AUD","date":"2017-07-28","rates":{"BGN":1.3276,"BRL":2.5126,"CAD":0.99864,"CHF":0.77091,"CNY":5.3684,"CZK":17.681,"DKK":5.0478,"GBP":0.60798,"HKD":6.2186,"HRK":5.0312,"HUF":206.98,"IDR":10616.0,"ILS":2.835,"INR":51.083,"JPY":88.494,"KRW":894.38,"MXN":14.125,"MYR":3.4095,"NOK":6.326,"NZD":1.0653,"PHP":40.189,"PLN":2.8844,"RON":3.0939,"RUB":47.402,"SEK":6.4726,"SGD":1.0825,"THB":26.572,"TRY":2.8144,"USD":0.79616,"ZAR":10.373,"EUR":0.67879}} -------------------------------------------------------------------------------- /test/inputs/json/misc/cfbce.json: -------------------------------------------------------------------------------- 1 | {"base":"EUR","date":"2017-07-28","rates":{"GBP":0.89568,"USD":1.1729}} -------------------------------------------------------------------------------- /test/inputs/json/misc/d0908.json: -------------------------------------------------------------------------------- 1 | {"total_population": [{"date": "2017-07-29", "population": 211366443}, {"date": "2017-07-30", "population": 211370963}]} -------------------------------------------------------------------------------- /test/inputs/json/misc/e64a0.json: -------------------------------------------------------------------------------- 1 | { 2 | "args": {}, 3 | "headers": { 4 | "Accept-Encoding": "identity", 5 | "Connection": "close", 6 | "Host": "httpbin.org", 7 | "User-Agent": "Python-urllib/3.6" 8 | }, 9 | "origin": "209.58.130.210", 10 | "url": "http://httpbin.org/get" 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/json/misc/faff5.json: -------------------------------------------------------------------------------- 1 | { 2 | "response": { 3 | "player_count": 9805198, 4 | "result": 1 5 | } 6 | } -------------------------------------------------------------------------------- /test/inputs/json/priority/combined-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | { 4 | "x": "one" 5 | }, 6 | { 7 | "x": "one" 8 | }, 9 | { 10 | "x": "one" 11 | }, 12 | { 13 | "x": "one" 14 | }, 15 | { 16 | "x": "one" 17 | }, 18 | { 19 | "x": "two" 20 | }, 21 | { 22 | "x": "two" 23 | }, 24 | { 25 | "x": "two" 26 | }, 27 | { 28 | "x": "two" 29 | }, 30 | { 31 | "x": "two" 32 | } 33 | ], 34 | "bar": [ 35 | { 36 | "x": "three" 37 | }, 38 | { 39 | "x": "three" 40 | }, 41 | { 42 | "x": "three" 43 | }, 44 | { 45 | "x": "three" 46 | }, 47 | { 48 | "x": "three" 49 | }, 50 | { 51 | "x": "three" 52 | }, 53 | { 54 | "x": "three" 55 | }, 56 | { 57 | "x": "three" 58 | }, 59 | { 60 | "x": "three" 61 | }, 62 | { 63 | "x": "three" 64 | } 65 | ] 66 | } 67 | -------------------------------------------------------------------------------- /test/inputs/json/priority/direct-recursive.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": true, 4 | "quux": "hullo", 5 | "moo": 3.1415, 6 | "also": { 7 | "foo": 123, 8 | "bar": true, 9 | "quux": "hullo", 10 | "moo": 3.1415 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/inputs/json/priority/empty-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | { 4 | "bar": "" 5 | }, 6 | { 7 | "bar": "" 8 | }, 9 | { 10 | "bar": "" 11 | }, 12 | { 13 | "bar": "" 14 | }, 15 | { 16 | "bar": "" 17 | }, 18 | { 19 | "bar": "" 20 | }, 21 | { 22 | "bar": "" 23 | }, 24 | { 25 | "bar": "" 26 | }, 27 | { 28 | "bar": "" 29 | }, 30 | { 31 | "bar": "" 32 | }, 33 | { 34 | "bar": "" 35 | }, 36 | { 37 | "bar": "" 38 | }, 39 | { 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /test/inputs/json/priority/identifiers.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": { 3 | "_": 123, 4 | "__": 123, 5 | "bla": {} 6 | }, 7 | "bla": { 8 | "bar": 123 9 | }, 10 | "!": 123, 11 | "": { 12 | "x": 123 13 | }, 14 | "Empty": { 15 | "y": 123 16 | }, 17 | "ThisIsA😜Tough\"\n\nOne": { 18 | "\"": 123, 19 | "\n\n\n": 123 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/inputs/json/priority/list.json: -------------------------------------------------------------------------------- 1 | {"data": 123, "next": {"data": 234, "next": {"data": 3456, "next": null}}} 2 | -------------------------------------------------------------------------------- /test/inputs/json/priority/name-style.json: -------------------------------------------------------------------------------- 1 | { 2 | "anEasyOne": 123, 3 | "PrettyEasyToo": true, 4 | "JSONString": "abc", 5 | "isMNISTLetter": true, 6 | "ZSR_HH_DEMO3_DELMATNR": true, 7 | "should_know_that_id_is_an_initialism": "yup", 8 | " spaces are separators too ": true 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/json/priority/no-classes.json: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /test/inputs/json/priority/number-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": { 3 | "^$#$%#@": 123, 4 | "$%@##%": 123.3, 5 | "$%#$%%#$%": 123 6 | } 7 | } -------------------------------------------------------------------------------- /test/inputs/json/priority/optional-union.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"a": 123}, 3 | {"a": "foo"}, 4 | {} 5 | ] 6 | -------------------------------------------------------------------------------- /test/inputs/json/priority/simple-identifiers.json: -------------------------------------------------------------------------------- 1 | { 2 | "": "empty", 3 | "x": "singleton", 4 | "{}": "weird", 5 | "x'": "single quote", 6 | "x\"": "double quote", 7 | "x y": "space", 8 | "continue": "common reserved word", 9 | "undefined": "common reserved word", 10 | "null": "common reserved word" 11 | } -------------------------------------------------------------------------------- /test/inputs/json/priority/union-constructor-clash.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": [123, true], 3 | "BoolInUnion": { 4 | "a": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/json/priority/unions.json: -------------------------------------------------------------------------------- 1 | { 2 | "x": [ 3 | 123, 4 | "abc", 5 | null 6 | ], 7 | "y": [ 8 | 123, 9 | null 10 | ], 11 | "z": [ 12 | 123, 13 | [1, 2, 3], 14 | {"a": true} 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /test/inputs/json/priority/url.json: -------------------------------------------------------------------------------- 1 | { "url": "foo", "fromURL": "bar" } 2 | -------------------------------------------------------------------------------- /test/inputs/json/samples/bitcoin-block.json: -------------------------------------------------------------------------------- 1 | { 2 | "hash": "00000000000000000039812e769f24205e041b453c293e27b62589875b4eb446", 3 | "time": 1500137916, 4 | "block_index": 1598634, 5 | "height": 475937, 6 | "txIndexes": [268140937, 268134345, 268134652, 268140434, 268140712, 268139704, 268139882, 268139006, 268139774, 268140216, 268139695, 268140160] 7 | } -------------------------------------------------------------------------------- /test/inputs/json/samples/getting-started.json: -------------------------------------------------------------------------------- 1 | { 2 | "greeting": "Welcome to quicktype!", 3 | "instructions": [ 4 | "Type or paste JSON here", 5 | "Or choose a sample above", 6 | 7 | "quicktype will generate code in your", 8 | "chosen language to parse the sample data" 9 | ] 10 | } -------------------------------------------------------------------------------- /test/inputs/json/samples/null-safe.json: -------------------------------------------------------------------------------- 1 | { 2 | "item": [ 3 | { 4 | "name": "RmondJone", 5 | "sex": 0, 6 | "address": { 7 | "street": "科技园路.", 8 | "city": "江苏苏州", 9 | "country": "中国" 10 | }, 11 | "created_at": "2015-04-24T01:46:50.459583Z" 12 | }, 13 | { 14 | "name": "David", 15 | "sex": null 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/inputs/json/samples/simple-object.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Lorem ipsum", 3 | "date": 1500137916, 4 | "validity": false 5 | } -------------------------------------------------------------------------------- /test/inputs/schema/a/test2.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "a/test2.json", 4 | "$ref": "../b/test3.json#/foo" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/accessors.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": 123, 3 | "enum": "red", 4 | "foo": "FOO!", 5 | "bar": "BAAAAR" 6 | } -------------------------------------------------------------------------------- /test/inputs/schema/accessors.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "union": { 5 | "oneOf": [ 6 | { 7 | "type": "boolean" 8 | }, 9 | { 10 | "type": "number" 11 | } 12 | ], 13 | "qt-accessors": ["presence", "amount"] 14 | }, 15 | "enum": { 16 | "type": "string", 17 | "enum": ["red", "green", "blue"], 18 | "qt-accessors": { 19 | "red": "fire", 20 | "green": "grass" 21 | } 22 | }, 23 | "foo": { 24 | "type": "string" 25 | }, 26 | "bar": { 27 | "type": "string" 28 | } 29 | }, 30 | "qt-accessors": { 31 | "union": "unionization", 32 | "enum": "enumerification", 33 | "foo": { 34 | "cs": "Fu_uu", 35 | "java": "Goo" 36 | }, 37 | "bar": { 38 | "go": "Bah", 39 | "*": "barre" 40 | } 41 | }, 42 | "required": ["union", "enum", "foo", "bar"], 43 | "additionalProperties": false 44 | } 45 | -------------------------------------------------------------------------------- /test/inputs/schema/any.1.json: -------------------------------------------------------------------------------- 1 | { "foo": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/any.2.json: -------------------------------------------------------------------------------- 1 | { "foo": [1, 2, 3] } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/any.3.json: -------------------------------------------------------------------------------- 1 | { "foo": { "bar": "abc" } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/any.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": {} 5 | }, 6 | "required": ["foo"] 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/b/test3.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "b/test3.json", 4 | "definitions": { 5 | "foo": { 6 | "$id": "#/foo", 7 | "type": "object", 8 | "properties": { 9 | "foo": { "type": "integer" } 10 | }, 11 | "required": ["foo"] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.1.fail.bool-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "quux", 3 | "nullable": null, 4 | "unionWithBool": true, 5 | "unionWithBoolAndEnum": false 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "true", 3 | "optional": "false", 4 | "nullable": "true", 5 | "arrOne": ["true", "false"], 6 | "arrNullable": ["true", null, "false"], 7 | "unionWithBool": "true", 8 | "unionWithBoolAndEnum": "false" 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.1.out.bool-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "true", 3 | "optional": "false", 4 | "nullable": "true", 5 | "arrOne": ["true", "false"], 6 | "arrNullable": ["true", null, "false"], 7 | "unionWithBool": true, 8 | "unionWithBoolAndEnum": false 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "true", 3 | "nullable": null, 4 | "unionWithBool": true, 5 | "unionWithBoolAndEnum": false 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "false", 3 | "nullable": null, 4 | "unionWithBool": true, 5 | "unionWithBoolAndEnum": "foo" 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/bool-string.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "one": { 5 | "type": "string", 6 | "format": "boolean" 7 | }, 8 | "optional": { 9 | "$ref": "#/properties/one" 10 | }, 11 | "nullable": { 12 | "oneOf": [ 13 | { 14 | "type": "null" 15 | }, 16 | { 17 | "$ref": "#/properties/one" 18 | } 19 | ] 20 | }, 21 | "arrOne": { 22 | "type": "array", 23 | "items": { 24 | "$ref": "#/properties/one" 25 | } 26 | }, 27 | "arrNullable": { 28 | "type": "array", 29 | "items": { 30 | "$ref": "#/properties/nullable" 31 | } 32 | }, 33 | "unionWithBool": { 34 | "oneOf": [ 35 | { "type": "boolean" }, 36 | { 37 | "$ref": "#/properties/one" 38 | } 39 | ] 40 | }, 41 | "unionWithBoolAndEnum": { 42 | "oneOf": [ 43 | { "type": "boolean" }, 44 | { 45 | "$ref": "#/properties/one" 46 | }, 47 | { "enum": ["foo"] } 48 | ] 49 | } 50 | }, 51 | "required": ["one", "nullable", "unionWithBool", "unionWithBoolAndEnum"] 52 | } 53 | -------------------------------------------------------------------------------- /test/inputs/schema/camelCase.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "myProperty": { 5 | "type": "string" 6 | }, 7 | "secondProperty": { 8 | "type": "string" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/schema/camelCase1.json: -------------------------------------------------------------------------------- 1 | { 2 | "myProperty": "first value", 3 | "secondProperty": "The second value" 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/class-map-union.1.fail.union.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": { 3 | "foo": { 4 | "quux": "foo" 5 | }, 6 | "bar": { 7 | "quux": "bar" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/class-map-union.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": { 3 | "foo": 3.1415 4 | } 5 | } -------------------------------------------------------------------------------- /test/inputs/schema/class-map-union.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": { 3 | "bar": "abc" 4 | } 5 | } -------------------------------------------------------------------------------- /test/inputs/schema/class-map-union.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": { 3 | "foo": true, 4 | "bar": false 5 | } 6 | } -------------------------------------------------------------------------------- /test/inputs/schema/class-map-union.4.json: -------------------------------------------------------------------------------- 1 | { 2 | "union": { 3 | "foo": { 4 | "quux": 123 5 | }, 6 | "bar": { 7 | "quux": 456 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /test/inputs/schema/class-with-additional.1.fail.union.json: -------------------------------------------------------------------------------- 1 | { 2 | "map": { 3 | "foo": 3.1415, 4 | "bar": "foo" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/class-with-additional.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "map": { 3 | "foo": 3.1415, 4 | "bar": true 5 | } 6 | } -------------------------------------------------------------------------------- /test/inputs/schema/class-with-additional.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "map": { 6 | "type": "object", 7 | "properties": { 8 | "foo": { 9 | "type": "number" 10 | } 11 | }, 12 | "additionalProperties": { 13 | "type": "boolean" 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /test/inputs/schema/constructor.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/constructor.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "constructor": { 5 | "oneOf": [ 6 | { "type": "number" }, 7 | { "type": "object", "additionalProperties": false, "title": "constructor" } 8 | ], 9 | "title": "union_constructor" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/inputs/schema/cut-enum.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 1 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/cut-enum.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { 5 | "type": [ 6 | "integer" 7 | ], 8 | "enum": [ 9 | 1, 10 | 2, 11 | true, 12 | "a", 13 | "b", 14 | "c" 15 | ] 16 | } 17 | }, 18 | "required": [ 19 | "foo" 20 | ] 21 | } -------------------------------------------------------------------------------- /test/inputs/schema/date-time-or-string.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { 5 | "oneOf": [ 6 | { 7 | "type": "string" 8 | }, 9 | { 10 | "type": "string", 11 | "format": "date-time" 12 | } 13 | ] 14 | }, 15 | "bar": { 16 | "oneOf": [ 17 | { 18 | "type": "string", 19 | "format": "date-time" 20 | }, 21 | { 22 | "enum": ["quux"] 23 | } 24 | ] 25 | } 26 | }, 27 | "required": ["foo", "bar"] 28 | } 29 | -------------------------------------------------------------------------------- /test/inputs/schema/date-time.1.fail.date-time.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": "In the year of the lord 1985 on April the 12th", 3 | "time": "23:20:50.52Z", 4 | "date-time": "On the 1985-04-12 at 23:20:50.52Z", 5 | "union-array": ["1985-04-12", "23:20:50.52Z"], 6 | "complex-union-array": ["1985-04-12T23:20:50.52Z", "foo", 123] 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/date-time.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": "1985-04-12", 3 | "time": "23:20:50.52Z", 4 | "date-time": "2018-08-13T21:31:01+01:00", 5 | "union-array": ["1985-04-12", "23:20:50.52Z"], 6 | "complex-union-array": ["2018-08-13T21:31:01+00:10", "foo", 123] 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/description-with-double-quotes.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": true 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/description-with-double-quotes.schema: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Cool \"stuff\"", 3 | "type": "object", 4 | "properties": { 5 | "foo": { 6 | "type": "boolean" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/description.1.json: -------------------------------------------------------------------------------- 1 | { "union": 123, "enum": "foo", "object-or-string": "abc" } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/description.2.json: -------------------------------------------------------------------------------- 1 | { "union": "bla", "enum": "bar", "object-or-string": { "prop": 123 } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/description.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "description": "The top-level class.\nIts description has two lines.", 4 | "properties": { 5 | "union": { 6 | "type": ["number", "string"], 7 | "description": "Either a number or a string" 8 | }, 9 | "enum": { 10 | "type": "string", 11 | "enum": ["foo", "bar"], 12 | "description": "An enumeration" 13 | }, 14 | "foo": { 15 | "type": "number" 16 | }, 17 | "bar": { 18 | "type": "boolean", 19 | "description": "A pretty boolean" 20 | }, 21 | "object-or-string": { 22 | "type": ["object", "string"], 23 | "properties": { 24 | "prop": { 25 | "type": "number", 26 | "description": "This must not get lost" 27 | } 28 | }, 29 | "required": ["prop"] 30 | } 31 | }, 32 | "required": ["union", "enum", "object-or-string"], 33 | "additionalProperties": false 34 | } 35 | -------------------------------------------------------------------------------- /test/inputs/schema/direct-union.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "stuff": { 3 | "one": { 4 | "required": null 5 | }, 6 | "two": { 7 | "required": "abc", 8 | "optional": null 9 | }, 10 | "three": { 11 | "required": { 12 | "foo": 123 13 | }, 14 | "optional": [ 15 | 1, 16 | 2, 17 | 3 18 | ] 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /test/inputs/schema/direct-union.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "stuff": { 6 | "type": "object", 7 | "additionalProperties": { 8 | "$ref": "#/definitions/thing" 9 | } 10 | } 11 | }, 12 | "required": [ 13 | "stuff" 14 | ], 15 | "definitions": { 16 | "thing": { 17 | "type": "object", 18 | "additionalProperties": false, 19 | "properties": { 20 | "required": { 21 | "$ref": "#/definitions/anything" 22 | }, 23 | "optional": { 24 | "$ref": "#/definitions/anything" 25 | } 26 | }, 27 | "required": [ 28 | "required" 29 | ] 30 | }, 31 | "anything": { 32 | "type": [ 33 | "string", 34 | "number", 35 | "integer", 36 | "boolean", 37 | "object", 38 | "array", 39 | "null" 40 | ] 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /test/inputs/schema/enum-with-null.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "enum": "foo" 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/enum-with-null.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "enum": null 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/enum-with-null.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "enum": { 6 | "type": ["string", "null"], 7 | "enum": ["foo", "bar", null] 8 | } 9 | }, 10 | "required": ["enum"] 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/schema/enum-with-values.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "weekdays": { 5 | "type": "string", 6 | "enum": [ 7 | "Monday", 8 | "Tuesday", 9 | "Wednesday", 10 | "Thursday", 11 | "Friday", 12 | "Saturday", 13 | "Sunday" 14 | ], 15 | "qt-enum-values": { 16 | "Monday": "1", 17 | "Tuesday": "2", 18 | "Wednesday": "3", 19 | "Thursday": "4", 20 | "Friday": "5", 21 | "Saturday": "6", 22 | "Sunday": "7" 23 | } 24 | } 25 | }, 26 | "required": [ 27 | "weekdays" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.1.fail.enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "lvc": "goody-two-shoes", 3 | "gve": "neutral" 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "lvc": "chaotic", 3 | "gve": "neutral" 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.2.json: -------------------------------------------------------------------------------- 1 | { "gve": "good" } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "gve": "good", 3 | "arr": ["foo", 123, "bar"] 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.4.json: -------------------------------------------------------------------------------- 1 | { 2 | "gve": "good", 3 | "otherArr": ["foo", "bar", "if"] 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/enum.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "lvc": { 5 | "enum": ["lawful", "neutral", "chaotic"] 6 | }, 7 | "gve": { 8 | "type": "string", 9 | "enum": ["good", "neutral", "evil"] 10 | }, 11 | "arr": { 12 | "type": "array", 13 | "items": { 14 | "oneOf": [ 15 | { 16 | "enum": ["foo", "bar", "if"] 17 | }, 18 | { 19 | "type": "integer" 20 | } 21 | ] 22 | } 23 | }, 24 | "otherArr": { 25 | "type": "array", 26 | "items": { 27 | "enum": ["foo", "bar", "if"] 28 | } 29 | }, 30 | "for": { 31 | "type": "string" 32 | } 33 | }, 34 | "required": ["gve"] 35 | } 36 | -------------------------------------------------------------------------------- /test/inputs/schema/go-schema-pattern-properties.1.fail.json: -------------------------------------------------------------------------------- 1 | { 2 | "map": { 3 | "foo": "bar" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/go-schema-pattern-properties.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "map": { 3 | "foo": 123 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/go-schema-pattern-properties.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "map": { 5 | "type": "object", 6 | "patternProperties": { 7 | ".*": { "type": "integer" } 8 | } 9 | } 10 | }, 11 | "required": ["map"] 12 | } 13 | -------------------------------------------------------------------------------- /test/inputs/schema/id-no-address.1.json: -------------------------------------------------------------------------------- 1 | { "item": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/id-no-address.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://example.net/root.json", 3 | "type": "object", 4 | "properties": { 5 | "item": { "$ref": "#item" } 6 | }, 7 | "required": ["item"], 8 | "definitions": { 9 | "single": { 10 | "$id": "#item", 11 | "type": "integer" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/inputs/schema/id-root.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar": 123 3 | } -------------------------------------------------------------------------------- /test/inputs/schema/id-root.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://foo/root.json", 3 | "$ref": "#/definitions/foo", 4 | "definitions": { 5 | "foo": { 6 | "type": "object", 7 | "properties": { 8 | "bar": { 9 | "$ref": "http://foo/root.json#/definitions/bar" 10 | } 11 | }, 12 | "required": ["bar"] 13 | }, 14 | "bar": { 15 | "type": "integer" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-all-of.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": true, 4 | "quux": "bla" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-all-of.schema: -------------------------------------------------------------------------------- 1 | { 2 | "allOf": [{ "$ref": "#/definitions/base1" }, { "$ref": "#/definitions/base2" }], 3 | "properties": { 4 | "foo": { "type": "integer" } 5 | }, 6 | "required": ["foo"], 7 | "definitions": { 8 | "base1": { 9 | "type": "object", 10 | "properties": { 11 | "bar": { "type": "boolean" } 12 | }, 13 | "required": ["bar"] 14 | }, 15 | "base2": { 16 | "type": "object", 17 | "properties": { 18 | "quux": { "type": "string" } 19 | }, 20 | "required": ["quux"] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.1.fail.union.json: -------------------------------------------------------------------------------- 1 | { "foo": ["bar", "quux"] } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.1.json: -------------------------------------------------------------------------------- 1 | { "foo": [1, 2, 3] } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.2.fail.union.json: -------------------------------------------------------------------------------- 1 | { "foo": { "bar": "quux" } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.2.json: -------------------------------------------------------------------------------- 1 | { "foo": { "bar": 123 } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.3.json: -------------------------------------------------------------------------------- 1 | { "foo": "abc" } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.4.json: -------------------------------------------------------------------------------- 1 | { "foo": true } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.5.json: -------------------------------------------------------------------------------- 1 | { "foo": 3.141592 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-class-array-union.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { 5 | "properties": { "bar": { "type": "integer" } }, 6 | "required": ["bar"], 7 | "items": { "type": "integer" } 8 | } 9 | }, 10 | "required": ["foo"] 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-one-of.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": true 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-one-of.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "quux": "bla" 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/implicit-one-of.schema: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [{ "$ref": "#/definitions/base1" }, { "$ref": "#/definitions/base2" }], 3 | "properties": { 4 | "foo": { "type": "integer" } 5 | }, 6 | "required": ["foo"], 7 | "definitions": { 8 | "base1": { 9 | "type": "object", 10 | "properties": { 11 | "bar": { "type": "boolean" } 12 | }, 13 | "required": ["bar"] 14 | }, 15 | "base2": { 16 | "type": "object", 17 | "properties": { 18 | "quux": { "type": "string" } 19 | }, 20 | "required": ["quux"] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-float-union.1.json: -------------------------------------------------------------------------------- 1 | { "number": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-float-union.2.json: -------------------------------------------------------------------------------- 1 | { "number": 3.141592 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-float-union.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "number": { 5 | "oneOf": [{ "type": "integer" }, { "type": "number" }] 6 | } 7 | }, 8 | "required": ["number"] 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.1.fail.integer-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "foo", 3 | "nullable": null, 4 | "unionWithInt": 123, 5 | "unionWithIntAndEnum": "foo" 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "123", 3 | "optional": "345", 4 | "nullable": "456", 5 | "arrOne": ["123", "234"], 6 | "arrNullable": ["123", null, "234"], 7 | "unionWithInt": "123", 8 | "unionWithIntAndEnum": "234" 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.1.out.integer-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrNullable": ["123", null, "234"], 3 | "arrOne": ["123", "234"], 4 | "nullable": "456", 5 | "one": "123", 6 | "optional": "345", 7 | "unionWithInt": 123, 8 | "unionWithIntAndEnum": 234 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "123", 3 | "nullable": null, 4 | "unionWithInt": 123, 5 | "unionWithIntAndEnum": 234 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "123", 3 | "nullable": null, 4 | "unionWithInt": 123, 5 | "unionWithIntAndEnum": "foo" 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/integer-string.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "one": { 5 | "type": "string", 6 | "format": "integer" 7 | }, 8 | "optional": { 9 | "$ref": "#/properties/one" 10 | }, 11 | "nullable": { 12 | "oneOf": [ 13 | { 14 | "type": "null" 15 | }, 16 | { 17 | "$ref": "#/properties/one" 18 | } 19 | ] 20 | }, 21 | "arrOne": { 22 | "type": "array", 23 | "items": { 24 | "$ref": "#/properties/one" 25 | } 26 | }, 27 | "arrNullable": { 28 | "type": "array", 29 | "items": { 30 | "$ref": "#/properties/nullable" 31 | } 32 | }, 33 | "unionWithInt": { 34 | "oneOf": [ 35 | { "type": "integer" }, 36 | { 37 | "$ref": "#/properties/one" 38 | } 39 | ] 40 | }, 41 | "unionWithIntAndEnum": { 42 | "oneOf": [ 43 | { "type": "integer" }, 44 | { 45 | "$ref": "#/properties/one" 46 | }, 47 | { "enum": ["foo"] } 48 | ] 49 | } 50 | }, 51 | "required": ["one", "nullable", "unionWithInt", "unionWithIntAndEnum"] 52 | } 53 | -------------------------------------------------------------------------------- /test/inputs/schema/intersection-nested.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "intersection": { 6 | "allOf": [ 7 | { 8 | "allOf": [ 9 | { 10 | "type": "number" 11 | } 12 | ] 13 | } 14 | ] 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/inputs/schema/intersection.1.fail.no-defaults.json: -------------------------------------------------------------------------------- 1 | { 2 | "intersection": {} 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/intersection.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "intersection": { 3 | "foo": 123 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/intersection.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "intersection": { 3 | "foo": 123, 4 | "bar": "abc" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/intersection.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "intersection": { 6 | "allOf": [ 7 | { 8 | "type": "object", 9 | "properties": { 10 | "foo": { 11 | "type": "number" 12 | } 13 | }, 14 | "required": ["foo"], 15 | "additionalProperties": true 16 | }, 17 | { 18 | "type": "object", 19 | "properties": { 20 | "bar": { 21 | "type": "string" 22 | } 23 | }, 24 | "additionalProperties": true 25 | } 26 | ] 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/inputs/schema/keyword-enum.1.json: -------------------------------------------------------------------------------- 1 | {"enum": "weak"} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/keyword-unions.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/keyword-unions.2.json: -------------------------------------------------------------------------------- 1 | { "constructor": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/list.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/list.2.json: -------------------------------------------------------------------------------- 1 | {"next": {}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/list.3.json: -------------------------------------------------------------------------------- 1 | {"next": {"next": {}}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/list.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/List", 3 | "definitions": { 4 | "List": { 5 | "type": "object", 6 | "properties": { 7 | "next": { 8 | "$ref": "#/definitions/List" 9 | } 10 | }, 11 | "title": "List", 12 | "description": "A recursive class type" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax-integer.1.fail.minmaxInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "free": -123, 3 | "min": 2, 4 | "max": -123, 5 | "minmax": 3, 6 | "union": 6, 7 | "minMaxUnion": 5, 8 | "intersection": 4, 9 | "minMaxIntersection": 4 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax-integer.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "free": -123, 3 | "min": 123, 4 | "max": -123, 5 | "minmax": 3, 6 | "union": 6, 7 | "minMaxUnion": 5, 8 | "intersection": 4, 9 | "minMaxIntersection": 4 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax-integer.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "free": { "type": "integer" }, 5 | "min": { 6 | "type": "integer", 7 | "minimum": 3 8 | }, 9 | "max": { 10 | "type": "integer", 11 | "maximum": 5 12 | }, 13 | "minmax": { 14 | "type": "integer", 15 | "minimum": 3, 16 | "maximum": 5 17 | }, 18 | "union": { 19 | "oneOf": [ 20 | { 21 | "$ref": "#/properties/minmax" 22 | }, 23 | { 24 | "type": "integer", 25 | "minimum": 4, 26 | "maximum": 6 27 | } 28 | ] 29 | }, 30 | "minMaxUnion": { 31 | "oneOf": [ 32 | { 33 | "$ref": "#/properties/min" 34 | }, 35 | { 36 | "$ref": "#/properties/max" 37 | } 38 | ] 39 | }, 40 | "intersection": { 41 | "allOf": [ 42 | { 43 | "$ref": "#/properties/union/oneOf/0" 44 | }, 45 | { 46 | "$ref": "#/properties/union/oneOf/1" 47 | } 48 | ] 49 | }, 50 | "minMaxIntersection": { 51 | "allOf": [ 52 | { 53 | "$ref": "#/properties/min" 54 | }, 55 | { 56 | "$ref": "#/properties/max" 57 | } 58 | ] 59 | } 60 | }, 61 | "required": ["free", "min", "max", "minmax", "union", "minMaxUnion", "intersection", "minMaxIntersection"] 62 | } 63 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax.1.fail.minmax.json: -------------------------------------------------------------------------------- 1 | { 2 | "free": -123, 3 | "min": 2, 4 | "max": -123, 5 | "minmax": 3, 6 | "union": 6, 7 | "minMaxUnion": 5, 8 | "intersection": 4, 9 | "minMaxIntersection": 4 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "free": -123, 3 | "min": 123, 4 | "max": -123, 5 | "minmax": 3, 6 | "union": 6, 7 | "minMaxUnion": 5, 8 | "intersection": 4, 9 | "minMaxIntersection": 4 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/minmax.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "free": { "type": "number" }, 5 | "min": { 6 | "type": "number", 7 | "minimum": 3 8 | }, 9 | "max": { 10 | "type": "number", 11 | "maximum": 5 12 | }, 13 | "minmax": { 14 | "type": "number", 15 | "minimum": 3, 16 | "maximum": 5 17 | }, 18 | "union": { 19 | "oneOf": [ 20 | { 21 | "$ref": "#/properties/minmax" 22 | }, 23 | { 24 | "type": "number", 25 | "minimum": 4, 26 | "maximum": 6 27 | } 28 | ] 29 | }, 30 | "minMaxUnion": { 31 | "oneOf": [ 32 | { 33 | "$ref": "#/properties/min" 34 | }, 35 | { 36 | "$ref": "#/properties/max" 37 | } 38 | ] 39 | }, 40 | "intersection": { 41 | "allOf": [ 42 | { 43 | "$ref": "#/properties/union/oneOf/0" 44 | }, 45 | { 46 | "$ref": "#/properties/union/oneOf/1" 47 | } 48 | ] 49 | }, 50 | "minMaxIntersection": { 51 | "allOf": [ 52 | { 53 | "$ref": "#/properties/min" 54 | }, 55 | { 56 | "$ref": "#/properties/max" 57 | } 58 | ] 59 | } 60 | }, 61 | "required": ["free", "min", "max", "minmax", "union", "minMaxUnion", "intersection", "minMaxIntersection"] 62 | } 63 | -------------------------------------------------------------------------------- /test/inputs/schema/minmaxlength.1.fail.minmaxlength.json: -------------------------------------------------------------------------------- 1 | { 2 | "minlength": "aa", 3 | "maxlength": "bbb", 4 | "minmaxlength": "cccc", 5 | "union": "dddddd", 6 | "inUnion": "cccc", 7 | "minMaxUnion": "eeeee", 8 | "intersection": "ffff", 9 | "minMaxIntersection": "gggg" 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/minmaxlength.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "minlength": "aaaa", 3 | "maxlength": "bbb", 4 | "minmaxlength": "cccc", 5 | "union": "dddddd", 6 | "inUnion": "cccc", 7 | "minMaxUnion": "eeeee", 8 | "intersection": "ffff", 9 | "minMaxIntersection": "gggg" 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/multi-type-enum.1.fail.union.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [1, 2, 3] 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/multi-type-enum.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 1 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/multi-type-enum.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": true 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/multi-type-enum.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "a" 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/multi-type-enum.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { 5 | "enum": [ 6 | 1, 7 | 2, 8 | true, 9 | "a", 10 | "b", 11 | "c" 12 | ] 13 | } 14 | }, 15 | "required": [ 16 | "foo" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/inputs/schema/mutually-recursive.1.json: -------------------------------------------------------------------------------- 1 | { "bar": { "foo": [{ "bar": { "foo": [] } }] } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/mutually-recursive.2.json: -------------------------------------------------------------------------------- 1 | { "bar": { "foo": {} } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/mutually-recursive.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/Foo", 3 | "definitions": { 4 | "Foo": { 5 | "type": "object", 6 | "properties": { 7 | "bar": { 8 | "$ref": "#/definitions/Bar" 9 | } 10 | }, 11 | "title": "Foo" 12 | }, 13 | "Bar": { 14 | "type": "object", 15 | "properties": { 16 | "foo": { 17 | "oneOf": [ 18 | { 19 | "$ref": "#/definitions/Foo" 20 | }, 21 | { "type": "array", 22 | "items": { "$ref": "#/definitions/Foo" } } 23 | ] 24 | } 25 | }, 26 | "required": ["foo"], 27 | "title": "Bar" 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/inputs/schema/non-standard-ref.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": 123, 4 | "quux": true 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/non-standard-ref.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { 5 | "type": "integer" 6 | }, 7 | "bar": { 8 | "$ref": "#/properties/foo" 9 | }, 10 | "quux": { 11 | "$ref": "#/bla/0" 12 | } 13 | }, 14 | "bla": [{ "type": "boolean" }], 15 | "required": ["foo", "bar", "quux"] 16 | } 17 | -------------------------------------------------------------------------------- /test/inputs/schema/object-type-required.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "abc", 3 | "bar": "def" 4 | } -------------------------------------------------------------------------------- /test/inputs/schema/object-type-required.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "abc" 3 | } -------------------------------------------------------------------------------- /test/inputs/schema/object-type-required.schema: -------------------------------------------------------------------------------- 1 | { 2 | "allOf": [ 3 | { 4 | "type": "object", 5 | "properties": { 6 | "foo": { 7 | "type": "string" 8 | } 9 | }, 10 | "required": [ 11 | "foo" 12 | ] 13 | }, 14 | { 15 | "oneOf": [ 16 | { 17 | "type": "object", 18 | "properties": { 19 | "bar": { 20 | "type": "string" 21 | } 22 | }, 23 | "required": [ 24 | "bar" 25 | ] 26 | }, 27 | { 28 | "type": "object", 29 | "additionalProperties": { 30 | "type": "string" 31 | } 32 | } 33 | ] 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /test/inputs/schema/optional-any.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/optional-any.2.json: -------------------------------------------------------------------------------- 1 | { "foo": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/optional-any.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "additionalProperties": false, 4 | "properties": { 5 | "foo": {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/pattern.1.fail.pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "pattern1": "qqq", 3 | "pattern2": "ba", 4 | "union": "ccc" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/pattern.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "pattern1": "aa", 3 | "pattern2": "ba", 4 | "union": "ccc" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/pattern.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "pattern1": { 5 | "type": "string", 6 | "pattern": "a[.]*" 7 | }, 8 | "pattern2": { 9 | "type": "string", 10 | "pattern": "b[.]*" 11 | }, 12 | "union": { 13 | "oneOf": [ 14 | { 15 | "$ref": "#/properties/pattern2" 16 | }, 17 | { 18 | "type": "string", 19 | "pattern": "c[.]*" 20 | } 21 | ] 22 | } 23 | }, 24 | "required": ["pattern1", "pattern2", "union"] 25 | } 26 | -------------------------------------------------------------------------------- /test/inputs/schema/postman-collection.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "response": [{ "body": "true" }] 4 | } 5 | -------------------------------------------------------------------------------- /test/inputs/schema/postman-collection.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "item": [ 3 | { 4 | "name": "foo", 5 | "response": [{ "body": "true" }] 6 | }, 7 | { 8 | "item": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/inputs/schema/postman-collection.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "description": "Postman collection", 4 | "$ref": "#/definitions/collection", 5 | "definitions": { 6 | "group": { 7 | "type": "object", 8 | "properties": { 9 | "item": { 10 | "type": "array", 11 | "items": { 12 | "$ref": "#/definitions/collection" 13 | } 14 | } 15 | } 16 | }, 17 | "item": { 18 | "type": "object", 19 | "properties": { 20 | "name": { "type": "string" }, 21 | "response": { 22 | "type": "array", 23 | "items": { 24 | "$ref": "#/definitions/response" 25 | } 26 | } 27 | } 28 | }, 29 | "response": { 30 | "type": "object", 31 | "properties": { 32 | "body": { "type": "string" } 33 | } 34 | }, 35 | "collection": { 36 | "oneOf": [ 37 | { "$ref": "#/definitions/group" }, 38 | { "$ref": "#/definitions/item" } 39 | ] 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/inputs/schema/ref-id-files.1.json: -------------------------------------------------------------------------------- 1 | { "foo": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/ref-id-files.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "test.json", 4 | "$ref": "a/test2.json#/" 5 | } -------------------------------------------------------------------------------- /test/inputs/schema/ref-remote.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/ref-remote.2.json: -------------------------------------------------------------------------------- 1 | {"next": {}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/ref-remote.3.json: -------------------------------------------------------------------------------- 1 | {"next": {"next": {}}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/ref-remote.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$id": "ref-remote.schema", 4 | "$ref": "https://raw.githubusercontent.com/quicktype/quicktype/master/test/inputs/schema/list.schema" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/required-draft3.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "longitude": { 5 | "type": "number", 6 | "required": true 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/inputs/schema/required-non-properties.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": [ 4 | 1, 5 | 2, 6 | 3 7 | ] 8 | } -------------------------------------------------------------------------------- /test/inputs/schema/required-non-properties.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { "type": "integer" } 5 | }, 6 | "required": ["foo", "bar"] 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/required.1.fail.no-defaults.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/required.schema: -------------------------------------------------------------------------------- 1 | { 2 | "allOf": [ 3 | { 4 | "type": "object", 5 | "properties": { 6 | "longitude": { 7 | "type": "number" 8 | } 9 | } 10 | }, 11 | { 12 | "required": [ 13 | "longitude" 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/inputs/schema/simple-ref.1.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/simple-ref.1.ref: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/List", 3 | "definitions": { 4 | "List": { 5 | "type": "object", 6 | "properties": { 7 | "next": { 8 | "$ref": "#/definitions/List" 9 | } 10 | }, 11 | "title": "List", 12 | "description": "A recursive class type" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/inputs/schema/simple-ref.2.json: -------------------------------------------------------------------------------- 1 | {"next": {}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/simple-ref.3.json: -------------------------------------------------------------------------------- 1 | {"next": {"next": {}}} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/simple-ref.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "simple-ref.1.ref#/definitions/List" 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/strict-optional.1.fail.strict-optional.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/inputs/schema/strict-optional.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": { "type": ["number", "null"] } 5 | }, 6 | "required": ["foo"] 7 | } 8 | -------------------------------------------------------------------------------- /test/inputs/schema/top-level-enum.1.json: -------------------------------------------------------------------------------- 1 | "one" -------------------------------------------------------------------------------- /test/inputs/schema/top-level-enum.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string", 3 | "enum": [ 4 | "one", 5 | "three", 6 | "two" 7 | ] 8 | } -------------------------------------------------------------------------------- /test/inputs/schema/top-level-primitive.schema: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://json-schema.org/geo", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "description": "Top level primitive", 5 | "type": "number" 6 | } 7 | -------------------------------------------------------------------------------- /test/inputs/schema/tuple.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "tuple": [123, true] 3 | } 4 | -------------------------------------------------------------------------------- /test/inputs/schema/tuple.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "tuple": { 5 | "type": "array", 6 | "items": [{ "type": "integer" }, { "type": "boolean" }] 7 | } 8 | }, 9 | "required": ["tuple"] 10 | } 11 | -------------------------------------------------------------------------------- /test/inputs/schema/union-list.1.json: -------------------------------------------------------------------------------- 1 | { "list": 123 } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/union-list.2.json: -------------------------------------------------------------------------------- 1 | { "list": { "next": 123 } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/union-list.3.json: -------------------------------------------------------------------------------- 1 | { "list": { "next": { "next": 123 } } } 2 | -------------------------------------------------------------------------------- /test/inputs/schema/union-list.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/TopLevel", 3 | "definitions": { 4 | "TopLevel": { 5 | "type": "object", 6 | "additionalProperties": false, 7 | "properties": { 8 | "list": { 9 | "$ref": "#/definitions/UnionList" 10 | } 11 | }, 12 | "required": [ 13 | "list" 14 | ] 15 | }, 16 | "UnionList": { 17 | "oneOf": [ 18 | { 19 | "type": "object", 20 | "additionalProperties": false, 21 | "properties": { 22 | "next": { 23 | "$ref": "#/definitions/UnionList" 24 | } 25 | }, 26 | "required": [ 27 | "next" 28 | ] 29 | }, 30 | { 31 | "type": "number" 32 | } 33 | ] 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /test/inputs/schema/union.1.json: -------------------------------------------------------------------------------- 1 | [{ "one": 123, "two": true }, { "two": false, "three": 3.1415 }] 2 | -------------------------------------------------------------------------------- /test/inputs/schema/union.schema: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/schema#", 3 | "type": "array", 4 | "items": { 5 | "oneOf": [ 6 | { 7 | "type": "object", 8 | "properties": { 9 | "one": { "type": "integer" }, 10 | "two": { "type": "boolean" } 11 | }, 12 | "required": ["one", "two"] 13 | }, 14 | { 15 | "type": "object", 16 | "properties": { 17 | "two": { "type": "boolean" }, 18 | "three": { "type": "number" } 19 | }, 20 | "required": ["two", "three"] 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/inputs/schema/uuid.1.fail.uuid.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "foo", 3 | "nullable": null, 4 | "unionWithEnum": "foo" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/uuid.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "68ffea67-509e-482e-90ca-e80e5709cd78", 3 | "optional": "891f6132-9749-4907-bd52-9d50ca47fe3a", 4 | "nullable": "22dc9756-bb07-4bdd-b975-700b23e8d3ca", 5 | "arrOne": ["a89b1ff1-2515-46ae-ae9b-bf2e278f63ea", "ac4095ec-1e94-4c2a-9180-8fd71bfcc0f6"], 6 | "arrNullable": ["5cb0e36e-641e-4e12-bf75-dfc9d489ea49", null, "439ccde9-27a6-44b9-b195-cf155aeab732"], 7 | "unionWithEnum": "a5004f81-17ea-4c2f-b652-262e4b103ad6" 8 | } 9 | -------------------------------------------------------------------------------- /test/inputs/schema/uuid.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "68ffea67-509e-482e-90ca-e80e5709cd78", 3 | "nullable": null, 4 | "unionWithEnum": "foo" 5 | } 6 | -------------------------------------------------------------------------------- /test/inputs/schema/uuid.schema: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "one": { 5 | "type": "string", 6 | "format": "uuid" 7 | }, 8 | "optional": { 9 | "$ref": "#/properties/one" 10 | }, 11 | "nullable": { 12 | "oneOf": [ 13 | { 14 | "type": "null" 15 | }, 16 | { 17 | "$ref": "#/properties/one" 18 | } 19 | ] 20 | }, 21 | "arrOne": { 22 | "type": "array", 23 | "items": { 24 | "$ref": "#/properties/one" 25 | } 26 | }, 27 | "arrNullable": { 28 | "type": "array", 29 | "items": { 30 | "$ref": "#/properties/nullable" 31 | } 32 | }, 33 | "unionWithEnum": { 34 | "oneOf": [ 35 | { 36 | "$ref": "#/properties/one" 37 | }, 38 | { "enum": ["foo"] } 39 | ] 40 | } 41 | }, 42 | "required": ["one", "nullable", "unionWithEnum"] 43 | } 44 | -------------------------------------------------------------------------------- /test/inputs/spotify-api/Artist.json: -------------------------------------------------------------------------------- 1 | { 2 | "external_urls": { 3 | "spotify": "https://open.spotify.com/artist/0OdUWJ0sBjDrqHygGUXeCF" 4 | }, 5 | "followers": { 6 | "href": null, 7 | "total": 306565 8 | }, 9 | "genres": ["indie folk", "indie pop"], 10 | "href": "https://api.spotify.com/v1/artists/0OdUWJ0sBjDrqHygGUXeCF", 11 | "id": "0OdUWJ0sBjDrqHygGUXeCF", 12 | "images": [ 13 | { 14 | "height": 816, 15 | "url": "https://i.scdn.co/image/eb266625dab075341e8c4378a177a27370f91903", 16 | "width": 1000 17 | }, 18 | { 19 | "height": 522, 20 | "url": "https://i.scdn.co/image/2f91c3cace3c5a6a48f3d0e2fd21364d4911b332", 21 | "width": 640 22 | }, 23 | { 24 | "height": 163, 25 | "url": "https://i.scdn.co/image/2efc93d7ee88435116093274980f04ebceb7b527", 26 | "width": 200 27 | }, 28 | { 29 | "height": 52, 30 | "url": "https://i.scdn.co/image/4f25297750dfa4051195c36809a9049f6b841a23", 31 | "width": 64 32 | } 33 | ], 34 | "name": "Band of Horses", 35 | "popularity": 59, 36 | "type": "artist", 37 | "uri": "spotify:artist:0OdUWJ0sBjDrqHygGUXeCF" 38 | } 39 | -------------------------------------------------------------------------------- /test/inputs/spotify-api/UserProfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "display_name" : "Lilla Namo", 3 | "external_urls" : { 4 | "spotify" : "https://open.spotify.com/user/tuggareutangranser" 5 | }, 6 | "followers" : { 7 | "href" : null, 8 | "total" : 4561 9 | }, 10 | "href" : "https://api.spotify.com/v1/users/tuggareutangranser", 11 | "id" : "tuggareutangranser", 12 | "images" : [ { 13 | "height" : null, 14 | "url" : "http://profile-images.scdn.co/artists/default/d4f208d4d49c6f3e1363765597d10c4277f5b74f", 15 | "width" : null 16 | } ], 17 | "type" : "user", 18 | "uri" : "spotify:user:tuggareutangranser" 19 | } -------------------------------------------------------------------------------- /test/inputs/urls/github.json: -------------------------------------------------------------------------------- 1 | { 2 | "repos": 3 | [ 4 | "https://api.github.com/users/", 5 | { "oneOf": [ "schani", "dvdsgl" ]}, 6 | "/repos" 7 | ], 8 | "issues": 9 | [ 10 | "https://api.github.com/repos/schani/", 11 | { "oneOf": [ "mathmap", "clickr", "clojurec" ]}, 12 | "/issues" 13 | ] 14 | } -------------------------------------------------------------------------------- /test/make-keyword-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./keywords.py >./inputs/json/priority/keywords.json 4 | ./keywords.py --enums >./inputs/schema/keyword-enum.schema 5 | ./keywords.py --unions >./inputs/schema/keyword-unions.schema 6 | -------------------------------------------------------------------------------- /test/run-for-all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | LANGUAGE="swift" 4 | OPTIONS="--just-types" 5 | 6 | set -o errexit 7 | set -o nounset 8 | set -o pipefail 9 | 10 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 11 | 12 | SCHEMA_INPUT_DIR="$__dir/../test/inputs/schema" 13 | JSON_INPUT_DIR="$__dir/../test/inputs/json" 14 | 15 | OUTPUT_DIR="$1" 16 | 17 | cd "$SCHEMA_INPUT_DIR" 18 | for fn in `find . -name '*.schema'` ; do 19 | echo $fn 20 | fdir=`dirname "$fn"` 21 | fbase=`basename "$fn" .schema` 22 | odir="$OUTPUT_DIR/schema/$fdir" 23 | mkdir -p "$odir" 24 | node "$__dir/../dist/cli/index.js" --lang "$LANGUAGE" $OPTIONS --src-lang schema --quiet -o "$odir/$fbase.$LANGUAGE" "$fn" 25 | done 26 | 27 | cd "$JSON_INPUT_DIR" 28 | for fn in `find . -name '*.json'` ; do 29 | echo $fn 30 | fdir=`dirname "$fn"` 31 | fbase=`basename "$fn" .json` 32 | odir="$OUTPUT_DIR/json/$fdir" 33 | mkdir -p "$odir" 34 | node "$__dir/../dist/cli/index.js" --lang "$LANGUAGE" $OPTIONS --quiet -o "$odir/$fbase.$LANGUAGE" "$fn" 35 | done 36 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "compilerOptions": { 4 | "strict": true, 5 | "alwaysStrict": true, 6 | "noUnusedLocals": true, 7 | "noUnusedParameters": true, 8 | "resolveJsonModule": true 9 | }, 10 | "include": ["*.ts", "../dist/*.js", "../dist/*.d.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node18/tsconfig.json", 3 | "compilerOptions": { 4 | "lib": ["ES2022", "dom"], 5 | "allowJs": false, 6 | "declaration": true, 7 | "typeRoots": ["node_modules/@types"], 8 | "strict": true, 9 | "noUnusedLocals": true, 10 | "noUnusedParameters": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "outDir": "dist", 13 | "baseUrl": "src", 14 | "resolveJsonModule": true 15 | }, 16 | "include": ["src"] 17 | } 18 | --------------------------------------------------------------------------------