구성
구성은 클라이언트/디버거 팩터리 옵션, prepare()와 send()에 전달하는 SendOptions 객체, 프로토콜별 옵션의 세 계층으로 나뉩니다.
팩터리 옵션
CreateClientOptions
createClient(options?)에 전달합니다. 모든 필드는 선택 사항입니다.
| 필드 | 타입 | 설명 |
|---|---|---|
writeBack | WriteBackOptions | 응답을 명세에 병합하는 방식을 제어합니다 |
response | ToResponseOptions | 응답 객체의 정규화 방식을 제어합니다 |
import { createClient } from "@powerduck/openapi-request";
const client = createClient({
writeBack: {
overwriteExamples: true,
// ... other WriteBackOptions
},
response: {
includeExamples: false,
// ... other ToResponseOptions
},
});
DebuggerOptions
createDebugger(config?)에 전달합니다. 모든 필드는 선택 사항입니다.
| 필드 | 타입 | 설명 |
|---|---|---|
adapters | ProtocolAdapter[] | 사용자 정의 어댑터 목록(기본 어댑터 전체를 대체) |
extraAdapters | ProtocolAdapter[] | 기본 레지스트리에 추가할 어댑터 |
writeBack | WriteBackOptions | 명세 반영 옵션 |
response | ToResponseOptions | 응답 정규화 옵션 |
writeBackTruncated | boolean | 잘린 스트림에서 추론한 스키마를 반영합니다(기본값: true) |
import { createDebugger, HttpAdapter, WebSocketAdapter } from "@powerduck/openapi-request";
// Use only HTTP and WebSocket adapters
const debugger1 = createDebugger({
adapters: [new HttpAdapter(), new WebSocketAdapter()],
});
// Add a custom adapter to the defaults
const debugger2 = createDebugger({
extraAdapters: [new MyCustomAdapter()],
writeBackTruncated: true,
});