Skip to content

Commit

Permalink
Add test for FieldNameTag
Browse files Browse the repository at this point in the history
  • Loading branch information
balki committed Apr 18, 2023
1 parent da6de4c commit 7f2e6ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fixtures/test_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/invopop/jsonschema/config",
"$ref": "#/$defs/Config",
"$defs": {
"Config": {
"properties": {
"name": {
"type": "string"
},
"count": {
"type": "integer"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"count"
]
}
}
}
12 changes: 12 additions & 0 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,15 @@ func TestArrayFormat(t *testing.T) {
pt := p.Items.Format
require.Equal(t, pt, "uri")
}

func TestFieldNameTag(t *testing.T) {
type Config struct {
Name string `yaml:"name"`
Count int `yaml:"count"`
}

r := Reflector{
FieldNameTag: "yaml",
}
compareSchemaOutput(t, "fixtures/test_config.json", &r, &Config{})
}

0 comments on commit 7f2e6ff

Please sign in to comment.