persona-community-5/.pnpm-store/v3/files/04/19b50eb7bcac47dd554b2e087e82bbd425b9d6ae35652f95213b65fdb7c1d53d40194d547c763b21256f2019751cc1f5469e926133e91f9be4ce6ed3a40559
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

37 lines
1.2 KiB
Plaintext

import { validateDefinedAndNonEmpty } from '../utils';
import type { Oas3Rule } from '../../visitors';
import type { UserContext } from '../../walk';
/**
* Validation according to rfc7807 - https://datatracker.ietf.org/doc/html/rfc7807
*/
export const Operation4xxProblemDetailsRfc7807: Oas3Rule = () => {
return {
Response: {
skip(_, key: string | number) {
return !/4[Xx0-9]{2}/.test(`${key}`);
},
enter(response, { report, location }: UserContext) {
if (!response.content || !response.content['application/problem+json'])
report({
message: 'Response `4xx` must have content-type `application/problem+json`.',
location: location.key(),
});
},
MediaType: {
skip(_, key: string | number) {
return key !== 'application/problem+json';
},
enter(media, ctx: UserContext) {
validateDefinedAndNonEmpty('schema', media, ctx);
},
SchemaProperties(schema, ctx: UserContext) {
validateDefinedAndNonEmpty('type', schema, ctx);
validateDefinedAndNonEmpty('title', schema, ctx);
},
},
},
};
};