Skip to content

Guard optional schema in Media Type Objects#482

Merged
ahx merged 1 commit into
ahx:mainfrom
KirtashW17:fix/ISS-481-media-type-without-schema
May 29, 2026
Merged

Guard optional schema in Media Type Objects#482
ahx merged 1 commit into
ahx:mainfrom
KirtashW17:fix/ISS-481-media-type-without-schema

Conversation

@KirtashW17

Copy link
Copy Markdown
Contributor

A Media Type Object may omit schema (e.g. declare only example), but the builder called content_object['schema'].schema(...) unguarded for both request and response bodies, raising NoMethodError at load time.

Guard with &. so a schema-less media type imposes no body-schema constraint, consistent with content-less requests/responses. The request and response validators already short-circuit on a nil content_schema.

Fixes #481

A Media Type Object may omit `schema` (e.g. declare only `example`), but
the builder called `content_object['schema'].schema(...)` unguarded for
both request and response bodies, raising NoMethodError at load time.

Guard with `&.` so a schema-less media type imposes no body-schema
constraint, consistent with content-less requests/responses. The request
and response validators already short-circuit on a nil content_schema.

Fixes ahx#481
@KirtashW17 KirtashW17 requested a review from ahx as a code owner May 29, 2026 12:12
@ahx

ahx commented May 29, 2026

Copy link
Copy Markdown
Owner

Thanks @KirtashW17

I'll package this as 3.4.3 ASAP

@ahx ahx merged commit 3f26d31 into ahx:main May 29, 2026
17 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.

[BUG] NoMethodError: undefined method 'schema' for nil when a Media Type Object has no schema

2 participants