mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
13 lines
396 B
TypeScript
13 lines
396 B
TypeScript
import type {OpenAPIRef} from '@fluxer/openapi/src/OpenAPITypes';
|
|
|
|
export function validateOpenAPIComponentName(name: string): void {
|
|
if (!/^[A-Za-z0-9._-]+$/.test(name)) {
|
|
throw new Error(`Invalid OpenAPI schema name: ${name}`);
|
|
}
|
|
}
|
|
|
|
export function createOpenAPIComponentRef(name: string): OpenAPIRef {
|
|
validateOpenAPIComponentName(name);
|
|
return {$ref: `#/components/schemas/${name}`};
|
|
}
|