Skip to content

Commit 776a858

Browse files
jtarchiefcce
authored andcommitted
add enum tag to jsonschema (sashabaranov#962)
* fix jsonschema tests * ensure all run during PR Github Action * add test for struct to schema * add support for enum tag * support nullable tag
1 parent de330e6 commit 776a858

File tree

2 files changed

+1
-48
lines changed

2 files changed

+1
-48
lines changed

jsonschema/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Definition struct {
4848
AdditionalProperties any `json:"additionalProperties,omitempty"`
4949
// Whether the schema is nullable or not.
5050
Nullable bool `json:"nullable,omitempty"`
51-
// MaxContains specifies the maximum number of elements in an array that can match the schema.
51+
// MinContains specifies the minimum number of elements in an array that can match the schema.
5252
MinContains int `json:"minContains,omitempty"`
5353
}
5454

jsonschema/json_test.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -329,53 +329,6 @@ func TestStructToSchema(t *testing.T) {
329329
"additionalProperties":false
330330
}`,
331331
},
332-
{
333-
name: "Test with exclude mark",
334-
in: struct {
335-
Name string `json:"-"`
336-
}{
337-
Name: "Name",
338-
},
339-
want: `{
340-
"type":"object",
341-
"additionalProperties":false
342-
}`,
343-
},
344-
{
345-
name: "Test with no json tag",
346-
in: struct {
347-
Name string
348-
}{
349-
Name: "",
350-
},
351-
want: `{
352-
"type":"object",
353-
"properties":{
354-
"Name":{
355-
"type":"string"
356-
}
357-
},
358-
"required":["Name"],
359-
"additionalProperties":false
360-
}`,
361-
},
362-
{
363-
name: "Test with omitempty tag",
364-
in: struct {
365-
Name string `json:"name,omitempty"`
366-
}{
367-
Name: "",
368-
},
369-
want: `{
370-
"type":"object",
371-
"properties":{
372-
"name":{
373-
"type":"string"
374-
}
375-
},
376-
"additionalProperties":false
377-
}`,
378-
},
379332
}
380333

381334
for _, tt := range tests {

0 commit comments

Comments
 (0)