nodePackages.quicktype: init at 15.0.258#107168
Closed
evanjs wants to merge 1 commit intoNixOS:masterfrom
Closed
Conversation
Contributor
|
@GrahamcOfBorg build quicktype |
Member
Author
Would we need |
Contributor
|
Right now @GrahamcOfBorg seems to be having issues right now. and indeed nodePackages.quicktype would have been correct |
midchildan
approved these changes
Dec 20, 2020
Member
|
PR got combined with a few other node updates. Closing so that the update goes trough smoothly. |
10 tasks
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.
Motivation for this change
Things Done
quicktypetonode-packages.jsonnode-packages'generate.shto update node packagesExample Usage
Example
schema.jsonconversionsSource
schema.json{ "$id": "https://example.com/person.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Person", "type": "object", "properties": { "firstName": { "type": "string", "description": "The person's first name." }, "lastName": { "type": "string", "description": "The person's last name." }, "age": { "description": "Age in years which must be equal to or greater than zero.", "type": "integer", "minimum": 0 } } }C++
Invocation
quicktype -s schema --lang c++ schema.json > schema.cpp(schema.c++would also work)or
quicktype -s schema -o schema.cpp schema.jsonResult
Contents of
schema.cppHaskell
Invocation
quicktype -s schema --lang haskell schema.json > schema.hsResult
Contents of
schema.hs{-# LANGUAGE StrictData #-} {-# LANGUAGE OverloadedStrings #-} module QuickType ( Schema (..) , decodeTopLevel ) where import Data.Aeson import Data.Aeson.Types (emptyObject) import Data.ByteString.Lazy (ByteString) import Data.HashMap.Strict (HashMap) import Data.Text (Text) import Data.Vector (Vector) {-| age: Age in years which must be equal to or greater than zero. firstName: The person's first name. lastName: The person's last name. -} data Schema = Schema { ageSchema :: Maybe Int , firstNameSchema :: Maybe Text , lastNameSchema :: Maybe Text } deriving (Show) decodeTopLevel :: ByteString -> Maybe Schema decodeTopLevel = decode instance ToJSON Schema where toJSON (Schema ageSchema firstNameSchema lastNameSchema) = object [ "age" .= ageSchema , "firstName" .= firstNameSchema , "lastName" .= lastNameSchema ] instance FromJSON Schema where parseJSON (Object v) = Schema <$> v .:? "age" <*> v .:? "firstName" <*> v .:? "lastName"Rust
Invocation
quicktype -s schema -o schema.rs schema.jsonor
quicktype -s schema --lang rust schema.json > schema.rsContents of
schema.rs