Skip to content

Ignore format on boolean, object and array schemas - #1112

Merged
ahl merged 1 commit into
oxidecomputer:mainfrom
Indian-boult:ignore-format-on-non-string-types
Nov 20, 2026
Merged

ahl merged 1 commit into
oxidecomputer:mainfrom
Indian-boult:ignore-format-on-non-string-types

Conversation

@Indian-boult

Copy link
Copy Markdown
Contributor

A schema that puts format on a boolean, object or array type made typify panic with not 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_object now accept any format and ignore it. The null arm already does this, and the multi type path already keeps format only for the number, integer and string variants.

The new format-on-non-strings schema 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 the format keys removed.

I ran fmt, clippy with -D warnings, doc and the full workspace tests on 1.97.1.

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.

@ahl ahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good; thanks!

@ahl
ahl merged commit 64d21d1 into oxidecomputer:main Nov 20, 2026
7 checks passed
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.

2 participants