Skip to content

Use negotiated content-type to select schema#289

Merged
jhthorsen merged 2 commits into
jhthorsen:mainfrom
archey347:archey/fix-content-type
Jun 4, 2026
Merged

Use negotiated content-type to select schema#289
jhthorsen merged 2 commits into
jhthorsen:mainfrom
archey347:archey/fix-content-type

Conversation

@archey347
Copy link
Copy Markdown
Contributor

@archey347 archey347 commented Nov 19, 2025

Summary

  • Fix regex on content-type for array coercion
  • Use negotiated content-type to select schema from api spec

Motivation

Adding parameters to content-type (e.g. json/application; charset=utf8) causes the validation to be completely bypassed. multipart/form in fact requires to have a boundary option.

The current implementation appears to use the content type provided by the client. This means that if the content type has additional parameters, it doesn't find a schema to validate against, so just uses an empty schema.

By using the content-type from the negotiation (and thus originally derived from the spec), in theory we should always find an appropriate schema.

However, as there's also a bug in the mojolicious-plugin-openapi which means we don't validate file uploads, this will probably break stuff unless deployed at the same time as jhthorsen/mojolicious-plugin-openapi#266 , which might make the packaging/dependency fun.

Possibly an an alternative could be to disallow any parameters going into json-validator, and force the openapi plugin to strip them instead.

References

Related: #284,

I think this also fixes jhthorsen/mojolicious-plugin-openapi#261

@archey347 archey347 changed the title Archey/fix content type Strip parameters from content-type before passing to validation, Fix resulting issues with multipart/form-data validation Nov 19, 2025
@archey347 archey347 changed the title Strip parameters from content-type before passing to validation, Fix resulting issues with multipart/form-data validation Use negotiated content-type to select schema Nov 19, 2025
@archey347 archey347 marked this pull request as ready for review November 19, 2025 12:04
@jhthorsen jhthorsen added the bug label Jun 4, 2026
@jhthorsen
Copy link
Copy Markdown
Owner

Thanks!

@jhthorsen jhthorsen merged commit 65483f5 into jhthorsen:main Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Content-Type: application/json' set more than once bug?

2 participants