Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp
396 B
Raw Blame
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}`};
}