documentOperationResponses method Null safety

  1. @override
Map<String, APIResponse> documentOperationResponses(
  1. APIDocumentContext context,
  2. Operation? operation
)
override

Returns a map of possible responses for operation.

To provide documentation for an operation, you must override this method and return a map of possible responses. The key is a String representation of a status code (e.g., "200") and the value is an APIResponse object.

Implementation

@override
Map<String, APIResponse> documentOperationResponses(
  APIDocumentContext context,
  Operation? operation,
) {
  return {
    "200": APIResponse.schema(
      "Successfully exchanged credentials for token",
      APISchemaObject.object({
        "access_token": APISchemaObject.string(),
        "token_type": APISchemaObject.string(),
        "expires_in": APISchemaObject.integer(),
        "refresh_token": APISchemaObject.string(),
        "scope": APISchemaObject.string()
      }),
      contentTypes: ["application/json"],
    ),
    "400": APIResponse.schema(
      "Invalid credentials or missing parameters.",
      APISchemaObject.object({"error": APISchemaObject.string()}),
      contentTypes: ["application/json"],
    )
  };
}