documentAPI method Null safety

Future<APIDocument> documentAPI(
  1. Map<String, dynamic> projectSpec

Creates an OpenAPI document for the components and paths in this channel.

This method invokes entryPoint and prepare before starting the documentation process.

The documentation process first invokes documentComponents on this channel. Every controller in the channel will have its documentComponents methods invoked. Any declared property of this channel that implements APIComponentDocumenter will have its documentComponents method invoked. If there services that are part of the application, but not stored as properties of this channel, you may override documentComponents in your subclass to add them. You must call the superclass' implementation of documentComponents.

After components have been documented, APIOperationDocumenter.documentPaths is invoked on entryPoint. The controllers of the channel will add paths and operations to the document during this process.

This method should not be overridden.

projectSpec should contain the keys name, version and description.


Future<APIDocument> documentAPI(Map<String, dynamic> projectSpec) async {
  final doc = APIDocument()..components = APIComponents();
  final root = entryPoint;

  final context = APIDocumentContext(doc);

  doc.paths = root.documentPaths(context); = APIInfo(
      projectSpec["name"] as String?, projectSpec["version"] as String?,
      description: projectSpec["description"] as String?);

  await context.finalize();

  return doc;