Skip to content

Commit eaf77a0

Browse files
chore: apply feedback
1 parent 34b3ce2 commit eaf77a0

File tree

3 files changed

+87
-87
lines changed

3 files changed

+87
-87
lines changed

Diff for: website/docs/reference/openapi-generator/cli.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ sidebar_position: 2
77
## Overview
88

99
The `openapi-generator` CLI tool converts your `@api-ts/io-ts-http` `apiSpec` definition
10-
into an OpenAPI specification document. When you run this tool, it reads a TypeScript
11-
file containing your API definition and outputs the OpenAPI specification to stdout.
10+
into an OpenAPI 3.0 specification. When you run this tool, it reads a TypeScript file
11+
containing your API definition and outputs the OpenAPI specification to stdout.
1212

1313
## Usage syntax
1414

@@ -23,8 +23,7 @@ openapi-generator [OPTIONS] [FLAGS] <file>
2323

2424
## Options
2525

26-
- `--name`, `-n <string>`: Specifies the API name in the generated OpenAPI
27-
specification.
26+
- `--name`, `-n <string>`: Specifies the API name in the generated specification.
2827
- `--version`, `-v <string>`: Specifies the API version in the generated OpenAPI
2928
specification. If an `@version` JSDoc tag is present on the `apiSpec` export, that
3029
value takes precedence.

Diff for: website/docs/reference/openapi-generator/configuration.md

+79-78
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ sidebar_position: 3
88

99
You need to configure the generator to:
1010

11-
- Correctly interpret `io-ts` types from external packages
11+
- Correctly interpret `io-ts` types from external packages.
1212
- Define OpenAPI schemas for custom `io-ts` codecs that can't be automatically derived
13-
from the Abstract Syntax Tree (AST)
13+
from the Abstract Syntax Tree (AST).
1414

1515
## Preparing external types packages
1616

@@ -20,21 +20,21 @@ external package's `package.json`:
2020
1. Include source code in the published npm bundle by adding the source directory to the
2121
`files` array:
2222

23-
```json
24-
// package.json of the external types package
25-
{
26-
"name": "my-external-types",
27-
"version": "1.0.0",
28-
"files": [
29-
"dist/",
30-
"src/" // Include source code
31-
],
32-
"main": "dist/index.js",
33-
"types": "dist/index.d.ts",
34-
"source": "src/index.ts" // Add this field
35-
// ... rest of package.json
36-
}
37-
```
23+
```json
24+
// package.json of the external types package
25+
{
26+
"name": "my-external-types",
27+
"version": "1.0.0",
28+
"files": [
29+
"dist/",
30+
"src/" // Include source code
31+
],
32+
"main": "dist/index.js",
33+
"types": "dist/index.d.ts",
34+
"source": "src/index.ts" // Add this field
35+
// ... rest of package.json
36+
}
37+
```
3838

3939
2. Specify the source entry point using the `source` field (for example,
4040
`"source": "src/index.ts"`)
@@ -51,48 +51,49 @@ You can define schemas directly within the package that declares the custom code
5151
1. Create a file named `openapi-gen.config.js` in the root of the types package
5252

5353
2. Update the package's `package.json` to include:
54-
- The `customCodecFile` field pointing to this file
55-
- The config file in the `files` array
56-
57-
```json
58-
// package.json of the types package defining custom codecs
59-
{
60-
"name": "my-custom-codec-package",
61-
// ...
62-
"files": [
63-
"dist/",
64-
"src/",
65-
"openapi-gen.config.js" // Include the config file
66-
],
67-
"customCodecFile": "openapi-gen.config.js" // Point to the file
68-
// ...
69-
}
70-
```
54+
55+
- The `customCodecFile` field pointing to this file
56+
- The config file in the `files` array
57+
58+
```json
59+
// package.json of the types package defining custom codecs
60+
{
61+
"name": "my-custom-codec-package",
62+
// ...
63+
"files": [
64+
"dist/",
65+
"src/",
66+
"openapi-gen.config.js" // Include the config file
67+
],
68+
"customCodecFile": "openapi-gen.config.js" // Point to the file
69+
// ...
70+
}
71+
```
7172

7273
3. Structure the `openapi-gen.config.js` file as follows:
7374

74-
```javascript
75-
// openapi-gen.config.js
76-
module.exports = (E) => {
77-
return {
78-
// Key matches the exported codec name (e.g., export const MyCustomString = ...)
79-
MyCustomString: () =>
80-
E.right({
81-
type: 'string',
82-
format: 'custom-format',
83-
description: 'A custom string type definition',
84-
}),
85-
AnotherCustomType: () =>
86-
E.right({
87-
type: 'object',
88-
properties: {
89-
/* ... */
90-
},
91-
}),
92-
// ... other custom codec definitions
93-
};
94-
};
95-
```
75+
```javascript
76+
// openapi-gen.config.js
77+
module.exports = (E) => {
78+
return {
79+
// Key matches the exported codec name (e.g., export const MyCustomString = ...)
80+
MyCustomString: () =>
81+
E.right({
82+
type: 'string',
83+
format: 'custom-format',
84+
description: 'A custom string type definition',
85+
}),
86+
AnotherCustomType: () =>
87+
E.right({
88+
type: 'object',
89+
properties: {
90+
/* ... */
91+
},
92+
}),
93+
// ... other custom codec definitions
94+
};
95+
};
96+
```
9697

9798
The exported function receives the `fp-ts/Either` namespace (`E`) as an argument. You
9899
should return an object where:
@@ -109,25 +110,25 @@ path via the `--codec-file` option:
109110

110111
2. Structure the file similarly to Method 1, but group definitions by package:
111112

112-
```javascript
113-
// custom-codecs.js
114-
module.exports = (E) => {
115-
return {
116-
'io-ts-bigint': {
117-
// Package name
118-
BigIntFromString: () => E.right({ type: 'string', format: 'bigint' }),
119-
NonZeroBigIntFromString: () =>
120-
E.right({ type: 'string', format: 'bigint' /* constraints */ }),
121-
// ... other codecs from 'io-ts-bigint'
122-
},
123-
'my-other-custom-package': {
124-
// Another package
125-
SomeType: () => E.right({ type: 'number', format: 'float' }),
126-
},
127-
// ... other packages
128-
};
129-
};
130-
```
113+
```javascript
114+
// custom-codecs.js
115+
module.exports = (E) => {
116+
return {
117+
'io-ts-bigint': {
118+
// Package name
119+
BigIntFromString: () => E.right({ type: 'string', format: 'bigint' }),
120+
NonZeroBigIntFromString: () =>
121+
E.right({ type: 'string', format: 'bigint' /* constraints */ }),
122+
// ... other codecs from 'io-ts-bigint'
123+
},
124+
'my-other-custom-package': {
125+
// Another package
126+
SomeType: () => E.right({ type: 'number', format: 'float' }),
127+
},
128+
// ... other packages
129+
};
130+
};
131+
```
131132

132133
In this structure:
133134

@@ -136,6 +137,6 @@ In this structure:
136137

137138
3. Run the generator with the `--codec-file` option:
138139

139-
```shell
140-
npx openapi-generator --codec-file ./custom-codecs.js src/index.ts
141-
```
140+
```shell
141+
npx openapi-generator --codec-file ./custom-codecs.js src/index.ts
142+
```

Diff for: website/docs/reference/openapi-generator/jsdoc.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You can use JSDoc comments to enrich the generated OpenAPI specification. This r
44
describes the supported annotations for both endpoint definitions and schema
55
definitions.
66

7-
## Endpoint annotations
7+
## Endpoint Annotations
88

99
You can add JSDoc comments to variables holding `h.httpRoute` definitions to provide
1010
metadata for the corresponding OpenAPI operation object.
@@ -158,12 +158,12 @@ const UserProfile = t.type({
158158
});
159159
```
160160

161-
### Supported OpenAPI tags
161+
### Supported OpenAPI Tags
162162

163163
You can use the following JSDoc tags, which map directly to standard OpenAPI schema
164164
keywords:
165165

166-
| JSDoc tag | OpenAPI property | Description |
166+
| JSDoc Tag | OpenAPI Property | Description |
167167
| ------------------------- | ------------------ | ---------------------------------- |
168168
| `@default <value>` | `default` | Default value |
169169
| `@example <value>` | `example` | Example value |
@@ -185,9 +185,9 @@ keywords:
185185
| `@format <format>` | `format` | Format (e.g., `uuid`, `date-time`) |
186186
| `@title <title>` | `title` | Schema title |
187187

188-
### Custom tags
188+
### Custom Tags
189189

190-
| JSDoc tag | OpenAPI property | Description |
190+
| JSDoc Tag | OpenAPI Property | Description |
191191
| ------------- | ------------------ | -------------------------------- |
192192
| `@private` | `x-internal: true` | Marks schema/field as internal |
193193
| `@deprecated` | `deprecated: true` | Marks schema/field as deprecated |

0 commit comments

Comments
 (0)