openapi_client_delegates

Openapi Client Delegates for printing and mocking openapi generated responses

Getting Started

Use this library for printing api responses generated by openapi

Usage

PrintingClientDelegate

ApiClient apiClient = ApiClient(
  basePath: 'Config.url',
  apiClientDelegate: PrintingClientDelegate(
    onResponse: (String requestLog) => print(requestLog),
    logLevels: {
      'a/call/you/dont/want/to/log/like/file/upload': LogLevel.none,
      'a/frequent/call': LogLevel.url,
    },
  ),
);

MockClientDelegate

const Map<String, String> responseMap = {
  '/auth/login': """{
  "success": true,
  "message": "SUCCESS",
  "data": {
    "accessToken": "908d1be3-a2ce-46b2-9548-edc435b736e9"
  }
}""",
  '/some-other-endpoint': """some-other-response""",
};

ApiClient apiClient = ApiClient(
  basePath: Config.url,
  apiClientDelegate: MockClientDelegate(
    responseMap: responseMap,
    onResponse: (String requestLog) => log(requestLog),
  ),
);

Libraries

openapi_client_delegates