openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Metadata generation

Open bddvlpr opened this issue 1 year ago • 0 comments

Description Currently, objects such as the Info Object and Server Object get ignored. I've written a set of PoC transformers that allows them to be generated into exported declarations like so.

/**
 * This file was auto-generated by openapi-typescript.
 * Do not make direct changes to the file.
 */

export const info = {
    title: "Test API Documentation",
    version: "1.12.1",
    contact: {
        name: "Test contact username",
        url: "https://...",
        email: "[email protected]"
    },
    license: {
        url: "https://...",
        name: "MIT"
    },
    description: "Test description"
};
export type paths = Record<string, never>;
export type webhooks = Record<string, never>;
export interface components {
    schemas: never;
    responses: never;
    parameters: never;
    requestBodies: never;
    headers: never;
    pathItems: never;
}
export type $defs = Record<string, never>;
export type operations = Record<string, never>;

The use-case being to (optionally) restrict baseUrl for openapi-fetch to the declared servers or other such cases where metadata is required; specification version mismatching, contact support,...

Proposal If the maintainer(s) think this is a valuable addition, I'd gladly help implementing it in the official library.

Checklist

bddvlpr avatar Apr 24 '24 05:04 bddvlpr