How to use the @anttiviljami/dtsgenerator/dist/core/referenceResolver function in @anttiviljami/dtsgenerator

To help you get started, we’ve selected a few @anttiviljami/dtsgenerator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anttiviljami / openapi-client-axios / src / typegen / typegen.ts View on Github external
export async function generateTypesForDocument(definition: Document | string) {
  const api = new OpenAPIClientAxios({ definition });
  await api.init();

  const processor = new WriteProcessor({ indentSize: 2, indentChar: ' ' });
  const resolver = new ReferenceResolver();
  const convertor = new SchemaConvertor(processor);

  const rootSchema = await SwaggerParser.bundle(definition);
  resolver.registerSchema(parseSchema(rootSchema));

  const generator = new DtsGenerator(resolver, convertor);
  const schemaTypes = await generator.generate();
  const exportedTypes = convertor.getExports();
  const operationTypings = generateOperationMethodTypings(api, exportedTypes);

  const imports = [
    'import {',
    '  OpenAPIClient,',
    '  Parameters,',
    '  UnknownParamsObject,',
    '  OperationResponse,',