Skip to content

Commit bf7396a

Browse files
update documentation
1 parent 2ebcd2a commit bf7396a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ $ openapi --help
4343
--name <value> Custom client class name
4444
--useOptions Use options instead of arguments
4545
--useUnionTypes Use union types instead of enums
46+
--exposeHeadersAndBody Return response headers and body
4647
--exportCore <value> Write core files to disk (default: true)
4748
--exportServices <value> Write services to disk (default: true)
4849
--exportModels <value> Write models to disk (default: true)
@@ -64,6 +65,7 @@ Documentation
6465
- [Client instances](docs/client-instances.md) `--name`
6566
- [Argument vs. Object style](docs/arguments-vs-object-style.md) `--useOptions`
6667
- [Enums vs. Union types](docs/enum-vs-union-types.md) `--useUnionTypes`
68+
- [Body vs. Headers and Body style](docs/body-vs-headers-and-body-style.md) `--exposeHeadersAndBody`
6769
- [Runtime schemas](docs/runtime-schemas.md) `--exportSchemas`
6870
- [Enum with custom names and descriptions](docs/custom-enums.md)
6971
- [Nullable props (OpenAPI v2)](docs/nullable-props.md)

docs/basic-usage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $ openapi --help
1313
--name <value> Custom client class name
1414
--useOptions Use options instead of arguments
1515
--useUnionTypes Use union types instead of enums
16+
--exposeHeadersAndBody Return response headers and body
1617
--exportCore <value> Write core files to disk (default: true)
1718
--exportServices <value> Write services to disk (default: true)
1819
--exportModels <value> Write models to disk (default: true)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Body vs. Headers and Body style
2+
3+
**Flag:** `--exposeHeadersAndBody`
4+
5+
By default, the OpenAPI generator creates service functions that return the response body (or a single response header).
6+
7+
```typescript
8+
public static createUser(
9+
requestBody?: User,
10+
): CancelablePromise<User> {
11+
// ...
12+
}
13+
```
14+
15+
Alternatively, use the flag `--exposeHeadersAndBody` to generate service functions that return the response headers and
16+
the response body.
17+
18+
```typescript
19+
public static createUser(
20+
requestBody?: User,
21+
): CancelablePromise<{ headers: Record<string, string>; body: User; }> {
22+
// ...
23+
}
24+
```

0 commit comments

Comments
 (0)