Repository navigation
Ignore format on boolean, object and array schemas - #1112
Merged
ahl merged 1 commit intoNov 20, 2026
Merged
Conversation
A schema such as `{"type": "object", "format": "date"}` fell through to the
`todo!()` at the end of `convert_schema_object` and panicked. The Finix API
spec in oxidecomputer/progenitor#1189 has one.
JSON Schema Validation section 7.1 says a format applies only to the
instance types it is defined for, and validation of any other type SHOULD
succeed. The formats JSON Schema and OpenAPI define are for strings and
numbers. The multi-type path already keeps `format` only for the number,
integer and string subschemas. The single-type boolean, object and array
arms now ignore it the same way, as the null arm already does.
The new format-on-non-strings schema test panics without this change. Its
output is identical to the output for the same schema with the format keys
removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A schema that puts
formaton a boolean, object or array type made typify panic withnot yet implemented: invalid (or unexpected) schema. The Finix API spec in oxidecomputer/progenitor#1189 has a date of birth object with"format": "date", which is where that report came from.JSON Schema Validation section 7.1 says a format applies to a set of instance types, and validation of any other type SHOULD succeed. The formats that JSON Schema and OpenAPI define are all for strings or numbers, so on these types the keyword has no effect.
The single type boolean, object and array arms of
convert_schema_objectnow accept anyformatand ignore it. The null arm already does this, and the multi type path already keepsformatonly for the number, integer and string variants.The new
format-on-non-stringsschema test covers an object, an object or null, a boolean, an array with items and an array of anything. It panics without the change. Its expected output is identical to what typify generates for the same schema with theformatkeys removed.I ran fmt, clippy with
-D warnings, doc and the full workspace tests on 1.97.1.