-
Notifications
You must be signed in to change notification settings - Fork 292
jsonschema: options for inference #185
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
Conversation
- Add ForOptions to hold options for schema inference. - Replace ForLax with ForOptions.IgnoreBadTypes. - Add an option to provide schemas for arbitrary types. - Provide a default mapping from types to schemas that includes stdlib types with MarshalJSON methods. - Add Schema.CloneSchemas. This is needed to make copies of the schemas in the above map: a schema cannot appear twice in a parent schema, because schema addresses matter when resolving internal references.
| TypeSchemas map[any]*Schema | ||
| } | ||
|
|
||
| // For constructs a JSON schema object for the given type argument. |
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.
// If non-nil, the provided options configures certain aspects of this contruction, described below.
(we need to document somewhere that opts may be nil)
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.
rewrote doc
jsonschema/infer.go
Outdated
|
|
||
| // ForOptions are options for the [For] function. | ||
| type ForOptions struct { | ||
| // If IgnoreBadTypes is true, fields that can't be represented as a JSON Schema |
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.
Is there any better word than 'Bad'? I'd say 'Unsupported' is better, but it's too long.
Probably Bad is best, I just wanted to note this decision.
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.
replaced with "Invalid"
- Add ForOptions to hold options for schema inference. - Replace ForLax with ForOptions.IgnoreBadTypes. - Add an option to provide schemas for arbitrary types. - Provide a default mapping from types to schemas that includes stdlib types with MarshalJSON methods. - Add Schema.CloneSchemas. This is needed to make copies of the schemas in the above map: a schema cannot appear twice in a parent schema, because schema addresses matter when resolving internal references.
Add ForOptions to hold options for schema inference.
Replace ForLax with ForOptions.IgnoreBadTypes.
Add an option to provide schemas for arbitrary types.
Provide a default mapping from types to schemas that includes stdlib types with MarshalJSON methods.
Add Schema.CloneSchemas. This is needed to make copies of the schemas in the above map: a schema cannot appear twice in a parent schema, because schema addresses matter when resolving internal references.