Built in rule to validate request and response media types #2438
Replies: 3 comments
-
Could you define a valid vs invalid MIME type in this context? Does valid mean "only things in the IANA list?" Because there's a lot. String comparisons never work because We could use a mime type validator, but I question the necessity of this feature compared to the overhead of writing it and running it. |
Beta Was this translation helpful? Give feedback.
-
Agree its a tricky one. @P0lip and I were discussing it on slack. Agree its a bit niche and it would likely need a base list + allow list to be defined. |
Beta Was this translation helpful? Give feedback.
-
Ok, if somebody can work up a PR and add the ability to extend them in all for it, but it’s not something we’ll have time to work on in house I think. Gotta focus on everything for v6 and other big features beyond that for the moment.
|
Beta Was this translation helpful? Give feedback.
-
User story.
As an API designer,
I want to have my api definition validated and checked that the content types are valid
So that I create beautiful consistent API definitions my consumers love
Is your feature request related to a problem?
Currently its possible to create unknown media types (well its always possible but it can introduce accidental errors such as
Describe the solution you'd like
Spectral could offer a build in allow / accept list of media types (expect the usual base set and perhaps some extension) to highlight where errors have been made as shown above
Additional context
Handmade rule based on https://github.com/openapi-contrib/style-guides/blob/c5326037027afb8bd0ce5a5d4ad88be7b048ef64/apisyouwonthate.yml#L130
Beta Was this translation helpful? Give feedback.
All reactions