persona-community-5/.pnpm-store/v3/files/c0/04d99b5a50005704dab4ba65c8c8b8ddb18c8ded7e319a25a7aeee34b5bab2dffb89d8c8854db942073b22aa8768afe3b0c02a0a875d77754ecbccba5fbe57
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

70 lines
2.0 KiB
Plaintext

import type { Oas3Rule } from '../../visitors';
import type { Problem, UserContext } from '../../walk';
import type { Location } from '../../ref-utils';
export const SpecComponentsInvalidMapName: Oas3Rule = () => {
const KEYS_REGEX = '^[a-zA-Z0-9\\.\\-_]+$';
function validateKey(
key: string | number,
report: (problem: Problem) => void,
location: Location,
component: string
) {
if (!new RegExp(KEYS_REGEX).test(key as string)) {
report({
message: `The map key in ${component} "${key}" does not match the regular expression "${KEYS_REGEX}"`,
location: location.key(),
});
}
}
return {
NamedSchemas: {
Schema(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'schemas');
},
},
NamedParameters: {
Parameter(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'parameters');
},
},
NamedResponses: {
Response(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'responses');
},
},
NamedExamples: {
Example(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'examples');
},
},
NamedRequestBodies: {
RequestBody(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'requestBodies');
},
},
NamedHeaders: {
Header(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'headers');
},
},
NamedSecuritySchemes: {
SecurityScheme(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'securitySchemes');
},
},
NamedLinks: {
Link(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'links');
},
},
NamedCallbacks: {
Callback(_node, { key, report, location }: UserContext) {
validateKey(key, report, location, 'callbacks');
},
},
};
};