documentOperationRequestBody method Null safety

  1. @override
APIRequestBody documentOperationRequestBody(
  1. APIDocumentContext context,
  2. Operation? operation
)
override

Returns a documented request body for operation.

If an operation method binds an Bind.body argument or accepts form data, this method returns a APIRequestBody that describes the bound body type. You may override this method to take an alternative approach or to augment the automatically generated request body documentation.

Implementation

@override
APIRequestBody documentOperationRequestBody(
  APIDocumentContext context,
  Operation? operation,
) {
  final body = super.documentOperationRequestBody(context, operation)!;
  body.content!["application/x-www-form-urlencoded"]!.schema!.isRequired = [
    "grant_type"
  ];
  body.content!["application/x-www-form-urlencoded"]!.schema!
      .properties!["password"]!.format = "password";
  return body;
}