Created
July 12, 2024 23:09
-
-
Save jmgilman/ef8ef3a1a9f95bd3580d5b6cd940c716 to your computer and use it in GitHub Desktop.
Generating Go struct from a CUE schema
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
package gen | |
//go:generate cue export -f --out openapi --outfile schema.json schema.cue | |
//go:generate oapi-codegen -config oapi-codegen.yml schema.json |
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
package: gen | |
output: schema.gen.go | |
generate: | |
models: true | |
output-options: | |
skip-prune: true |
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
#Schema: { | |
field1: string | |
field2: number | |
field3: bool | |
} |
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
// Package gen provides primitives to interact with the openapi HTTP API. | |
// | |
// Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT. | |
package gen | |
// Schema defines model for Schema. | |
type Schema struct { | |
Field1 string `json:"field1"` | |
Field2 float32 `json:"field2"` | |
Field3 bool `json:"field3"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment