documentComponents method Null safety

  1. @override
void documentComponents(
  1. APIDocumentContext context
)

Tells this object to add its components to context.

You may register components with context in this method. The order in which components are registered does not matter.

Example:

    class Car implements APIComponentDocumenter {
      @override
      void documentComponents(APIDocumentContext context) {
        context.schema.register("Car", APISchemaObject.object({
          "make": APISchemaObject.string(),
          "model": APISchemaObject.string(),
          "year": APISchemaObject.integer(),
        }));
      }
    }

See APIDocumentContext for more details.

Implementation

@override
void documentComponents(APIDocumentContext context) {
  final obj = document(context);
  context.schema.register(name, obj, representation: instanceType);
}