document static method Null safety

Future<APIDocument> document(
  1. Type type,
  2. ApplicationOptions config,
  3. Map<String, dynamic> projectSpec
)

Creates an APIDocument from an ApplicationChannel.

This method is called by the conduit document CLI.

Implementation

static Future<APIDocument> document(
  Type type,
  ApplicationOptions config,
  Map<String, dynamic> projectSpec,
) async {
  final runtime = RuntimeContext.current[type] as ChannelRuntime;

  await runtime.runGlobalInitialization(config);

  final server = ApplicationServer(runtime.channelType, config, 1);

  await server.channel.prepare();

  final doc = await server.channel.documentAPI(projectSpec);

  await server.channel.close();

  return doc;
}