WIP: Nested types#1
Merged
Merged
Conversation
dvdsgl
commented
Jul 13, 2017
Member
Author
There was a problem hiding this comment.
I recommend that we don't use StrMap in our model. It's just a lightweight alias for a foreign JavaScript object, and we'll have an easier time if we just use Array or Map.
dvdsgl
commented
Jul 13, 2017
Member
Author
There was a problem hiding this comment.
I think you could do:
(case _ of
[] -> ...
x : xs -> ...)
dvdsgl
commented
Jul 13, 2017
Member
Author
There was a problem hiding this comment.
CSArray :: CSharpType -> CSharpType, so I am not sure how you are applying it to a record here.
dvdsgl
commented
Jul 13, 2017
Member
Author
There was a problem hiding this comment.
You can write { x, ... } instead of { x: x, ... }.
Member
Author
|
Using gatherCSharpClassesFromJson :: String -> Json -> Tuple CSharpType (Array CSharpClass)
gatherCSharpClassesFromJson name json = foldJson
(const $ Tuple CSObject [])
(\b -> Tuple CSBool [])
(\x -> Tuple CSDouble [])
(\s -> Tuple CSString [])
(case _ of
[] -> Tuple (CSArray CSObject) []
x : _ ->
let Tuple et classes = gatherCSharpClassesFromJson (singularize name) x in
Tuple (CSArray et) classes)
(\o ->
let c = CSClass { name: name, properties: props }
Tuple props classes = mapProperties o in
Tuple (CSClassType c) (c : classes))
json |
Member
Author
|
Pulling the lambdas our into their own definitions also worked: gatherCSharpClassesFromJson name json = foldJson
(const $ Tuple CSObject [])
(\b -> Tuple CSBool [])
(\x -> Tuple CSDouble [])
(\s -> Tuple CSString [])
fromJArray
fromJObject
json
where
fromJObject o = Tuple (CSClassType c) (c : classes)
where c = CSClass { name: name, properties: props }
Tuple props classes = mapProperties o
fromJArray [] = Tuple (CSArray CSObject) []
fromJArray (x : _) = Tuple (CSArray et) classes
where Tuple et classes = gatherCSharpClassesFromJson (singularize name) x |
schani
pushed a commit
that referenced
this pull request
Aug 29, 2017
WIP: Nested types Original commit 3072488
schani
added a commit
to thives/quicktype
that referenced
this pull request
Jul 19, 2026
…eapps#1) Replace the Vitest unit test (which checked Rust output strings for one language) with a standard JSON Schema fixture exercising the same shape: an allOf nested inside a oneOf inside another oneOf, taken from the issue glideapps#2913 repro. The fixture runs against every language in CI, round-trips a positive instance, and expects failure on a malformed union member for languages with the "union" feature. Verified end-to-end locally with schema-golang and schema-typescript; all 22 CI target languages generate successfully from the schema. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.