-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
Would be nice to have the possibility to add other struct tags automatically from the schema, besides json, yaml and mapstructure.
For example, with https://github.com/brianvoe/gofakeit, we can generate random data for testing.
Here I'm picking $comment as the source of this metadata, but it's just an idea:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "https://example.com/case",
"type": "object",
"properties": {
"url": {
"type": "string",
"$comment": "$go-jsonschema-tag:fake:\"{url}\"",
"$comment": "Just a regular comment to be ignored..."
},
"id": {
"type": "string",
"$comment": "$go-jsonschema-tag:fake:\"{number:1,10}\""
},
"html": {
"type": "string",
"$comment": "$go-jsonschema-tag:fake:\"skip\""
}
}
}
It would generate something like this:
type Tags struct {
// Html corresponds to the JSON schema field "html".
Html *string `yaml:"html,omitempty" fake:"skip"`
// Id corresponds to the JSON schema field "id".
Id *string `yaml:"id,omitempty" fake:"{number:1,10}"`
// Url corresponds to the JSON schema field "url".
Url *string `yaml:"url,omitempty" fake:"{url}"`
}
Metadata
Metadata
Assignees
Labels
No labels