Skip to content

Conversation

@jba
Copy link
Contributor

@jba jba commented Jul 28, 2025

  • 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.

@jba jba requested review from findleyr and samthanawalla July 28, 2025 19:16
@jba jba force-pushed the js-for-options branch from 58d85f9 to 3e68a44 Compare July 28, 2025 19:18
- 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.
samthanawalla
samthanawalla previously approved these changes Jul 29, 2025
findleyr
findleyr previously approved these changes Jul 30, 2025
TypeSchemas map[any]*Schema
}

// For constructs a JSON schema object for the given type argument.
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewrote doc


// ForOptions are options for the [For] function.
type ForOptions struct {
// If IgnoreBadTypes is true, fields that can't be represented as a JSON Schema
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced with "Invalid"

@jba jba dismissed stale reviews from findleyr and samthanawalla via eadb28e July 30, 2025 20:57
@jba jba requested review from findleyr and samthanawalla July 30, 2025 20:57
@jba jba merged commit 1e40ede into modelcontextprotocol:main Aug 4, 2025
3 checks passed
BC-ACherednichenko pushed a commit to BC-ACherednichenko/go-sdk that referenced this pull request Aug 5, 2025
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants