documentComponents method

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

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) {
  super.documentComponents(context);

  context.responses.register(
    "InsufficientScope",
    APIResponse(
      "The provided credentials or bearer token have insufficient permission to access this route.",
      content: {
        "application/json": APIMediaType(
          schema: APISchemaObject.object({
            "error": APISchemaObject.string(),
            "scope": APISchemaObject.string()
              ..description = "The required scope for this operation."
          }),
        )
      },
    ),
  );

  context.responses.register(
    "InsufficientAccess",
    APIResponse(
      "The provided credentials or bearer token are not authorized for this request.",
      content: {
        "application/json": APIMediaType(
          schema: APISchemaObject.object(
            {"error": APISchemaObject.string()},
          ),
        )
      },
    ),
  );

  context.responses.register(
    "MalformedAuthorizationHeader",
    APIResponse(
      "The provided Authorization header was malformed.",
      content: {
        "application/json": APIMediaType(
          schema: APISchemaObject.object(
            {"error": APISchemaObject.string()},
          ),
        )
      },
    ),
  );
}