This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* generate jsonschema
- Loading branch information
Showing
20 changed files
with
1,196 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://github.com/hasura/ndc-rest-schema/command/convert-config", | ||
"$ref": "#/$defs/ConvertConfig", | ||
"$defs": { | ||
"ConvertConfig": { | ||
"properties": { | ||
"file": { | ||
"type": "string" | ||
}, | ||
"spec": { | ||
"$ref": "#/$defs/SchemaSpecType" | ||
}, | ||
"methodAlias": { | ||
"additionalProperties": { | ||
"type": "string" | ||
}, | ||
"type": "object" | ||
}, | ||
"trimPrefix": { | ||
"type": "string" | ||
}, | ||
"envPrefix": { | ||
"type": "string" | ||
}, | ||
"pure": { | ||
"type": "boolean" | ||
}, | ||
"strict": { | ||
"type": "boolean" | ||
}, | ||
"patchBefore": { | ||
"items": { | ||
"$ref": "#/$defs/PatchConfig" | ||
}, | ||
"type": "array" | ||
}, | ||
"patchAfter": { | ||
"items": { | ||
"$ref": "#/$defs/PatchConfig" | ||
}, | ||
"type": "array" | ||
}, | ||
"allowedContentTypes": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"output": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"file" | ||
] | ||
}, | ||
"PatchConfig": { | ||
"properties": { | ||
"path": { | ||
"type": "string" | ||
}, | ||
"strategy": { | ||
"type": "string", | ||
"enum": [ | ||
"merge", | ||
"json6902" | ||
] | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"path", | ||
"strategy" | ||
] | ||
}, | ||
"SchemaSpecType": { | ||
"type": "string", | ||
"enum": [ | ||
"oas3", | ||
"oas2", | ||
"openapi3", | ||
"openapi2", | ||
"ndc" | ||
] | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hasura/ndc-rest-schema/command" | ||
"github.com/hasura/ndc-rest-schema/schema" | ||
"github.com/invopop/jsonschema" | ||
) | ||
|
||
func main() { | ||
if err := jsonSchemaConvertConfig(); err != nil { | ||
panic(fmt.Errorf("failed to write jsonschema for ConvertConfig: %s", err)) | ||
} | ||
if err := jsonSchemaNdcRESTSchema(); err != nil { | ||
panic(fmt.Errorf("failed to write jsonschema for NDCRestSchema: %s", err)) | ||
} | ||
} | ||
|
||
func jsonSchemaConvertConfig() error { | ||
reflectSchema := jsonschema.Reflect(&command.ConvertConfig{}) | ||
schemaBytes, err := json.MarshalIndent(reflectSchema, "", " ") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return os.WriteFile("convert-config.jsonschema", schemaBytes, 0644) | ||
} | ||
|
||
func jsonSchemaNdcRESTSchema() error { | ||
reflectSchema := jsonschema.Reflect(&schema.NDCRestSchema{}) | ||
schemaBytes, err := json.MarshalIndent(reflectSchema, "", " ") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return os.WriteFile("ndc-rest-schema.jsonschema", schemaBytes, 0644) | ||
} |
Oops, something went wrong.