import { MetadataArgsStorage } from 'routing-controllers';
import { routingControllersToSpec } from 'routing-controllers-openapi';
import { config } from './config';

/**
 * This function generates a the openapi spec from route metadata and type schemas.
 * @param storage MetadataArgsStorage object generated by routing-controllers.
 * @param schemas MetadataArgsStorage object generated by class-validator-jsonschema.
 */
export function generateSpec(storage: MetadataArgsStorage, schemas) {
    return routingControllersToSpec(
        storage,
        {},
        {
            components: {
                schemas,
            },
            info: {
                description: "The the API for the LfK! document server.",
                title: "LfK! document server API",
                version: config.version
            },
        }
    );
}