-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor type handling for maps and types, removing YAML #23
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ jobs: | |
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.42 | ||
version: v1.45 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ linters: | |
- structcheck | ||
- stylecheck | ||
- exhaustive | ||
- varnamelen | ||
|
||
linters-settings: | ||
govet: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,11 @@ type User struct { | |
Tags map[string]interface{} `json:"tags,omitempty"` | ||
|
||
// An array of pets the user cares for. | ||
Pets []*nested.Pet `json:"pets"` | ||
Pets nested.Pets `json:"pets"` | ||
|
||
// Set of animal names to pets | ||
NamedPets nested.NamedPets `json:"named_pets"` | ||
|
||
// Set of plants that the user likes | ||
Plants []*nested.Plant `json:"plants" jsonschema:"title=Pants"` | ||
Plants []*nested.Plant `json:"plants" jsonschema:"title=Plants"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pants was so much better... 🤣 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://github.com/invopop/jsonschema/array-type", | ||
"$ref": "#/$defs/ArrayType", | ||
"$defs": { | ||
"ArrayType": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
{ | ||
"$schema": "http://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://github.com/invopop/jsonschema/pattern-test", | ||
"$ref": "#/$defs/PatternTest", | ||
"$schema": "http://json-schema.org/draft/2020-12/schema", | ||
"$defs": { | ||
"PatternTest": { | ||
"required": [ | ||
"with_pattern" | ||
], | ||
"properties": { | ||
"with_pattern": { | ||
"type": "string", | ||
"maxLength": 50, | ||
"minLength": 1, | ||
"pattern": "[0-9]{1,4}", | ||
"type": "string" | ||
"pattern": "[0-9]{1,4}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not making sense of this spec. Is If so, isn't the And if not, isn't this the same as That is to say: If the pattern isn't anchored, then in effect, we're just looking for a single digit in the string? And if it is anchored, then we'll never have a lenght beyond 4... But maybe I'm misunderstanding. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct, but this is just a test for the examples, the content isn't that meaningful :-) |
||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object" | ||
"type": "object", | ||
"required": [ | ||
"with_pattern" | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.46 just came out yesterday, I think :)