Skip to content

docs(openapi-generator): Refactor documentation to Diátaxis Reference format #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

youngjungithub
Copy link
Contributor

This PR significantly refactors the documentation for the @api-ts/openapi-generator package to align with the Reference section principles of the Diátaxis framework. The goal is to provide users with a clear, structured, and authoritative technical description suitable for direct consultation during development.

Key Changes:

  • Restructured the entire README.md into a dedicated Reference section, replacing the previous narrative format.
  • Organized content into logical subsections for improved navigability and focus:
    • Command-Line Interface (CLI): Provides a technical overview, usage syntax, and detailed descriptions of the <file> argument, options (--name, --version, --codec-file), and flags (--internal, --help), along with concrete usage examples.
    • Configuration: Clearly documents the requirements for preparing external types packages (specifying files and source in the external package's package.json). Details the two distinct methods for defining custom codec schemas:
      1. Via openapi-gen.config.js within the types package (recommended for type authors), including file naming, package.json requirements (customCodecFile, files), and file structure.
      2. Via the --codec-file CLI option for consumers, specifying the required file structure (grouping by package name).
    • Supported io-ts Primitives: Includes a definitive list of io-ts primitives and combinators that the generator can automatically interpret to produce OpenAPI schemas.
    • JSDoc Annotations: Exhaustively documents the supported JSDoc tags used to enrich the generated OpenAPI specification, categorized by:
      • Endpoint Annotations (applied to httpRoute variables): Covers Summary, Description, @operationId, @tag, @private, @unstable, @example, and the handling of unknown tags (x-unknown-tags), explaining their direct mapping to OpenAPI Operation Object fields (like summary, description, operationId, tags, x-internal, x-unstable, example, x-unknown-tags).
      • Schema Annotations (applied to io-ts types/fields): Details how to add descriptions via JSDoc text and lists all supported standard OpenAPI tags (@default, @example, @minLength, @maximum, @pattern, @format, etc.) and custom tags (@private, @deprecated), explaining their effect on the resulting OpenAPI Schema Object or Property (like description, default, minLength, deprecated, x-internal). Includes comprehensive examples demonstrating tag usage.
  • Removed introductory explanations and narrative prose, focusing strictly on factual, technical descriptions of the tool's features, configuration requirements, and behavior based on inputs (like JSDoc tags).

Impact:

This restructuring provides developers using @api-ts/openapi-generator with significantly improved technical reference documentation. The information is now presented in a consistent, predictable, and easily searchable format, adhering to the Diátaxis framework's guidelines for effective reference material. This makes it easier for users to find the specific technical details they need regarding CLI usage, configuration, supported types, and JSDoc annotation capabilities while working with the generator.

@youngjungithub youngjungithub requested review from a team as code owners April 21, 2025 16:48
@youngjungithub youngjungithub force-pushed the docs/refactor-openapi-generator-docs branch from e0fbf18 to 34b3ce2 Compare April 21, 2025 16:50
## Overview

The `openapi-generator` CLI tool converts your `@api-ts/io-ts-http` `apiSpec` definition
into an OpenAPI specification document. When you run this tool, it reads a TypeScript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
into an OpenAPI specification document. When you run this tool, it reads a TypeScript
into an OpenAPI 3.0 specification. When you run this tool, it reads a TypeScript

Comment on lines 26 to 27
- `--name`, `-n <string>`: Specifies the API name in the generated OpenAPI
specification.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `--name`, `-n <string>`: Specifies the API name in the generated OpenAPI
specification.
- `--name`, `-n <string>`: Specifies the API name in the generated specification.

You've already introduced the term OpenAPI 3.0 specification, so no need to say the full name every time. From this point forward on this page, simply use specification.


You need to configure the generator to:

- Correctly interpret `io-ts` types from external packages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Correctly interpret `io-ts` types from external packages
- Correctly interpret `io-ts` types from external packages.

Bullet points that form complete sentences should get periods.

You need to configure the generator to:

- Correctly interpret `io-ts` types from external packages
- Define OpenAPI schemas for custom `io-ts` codecs that can't be automatically derived
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Define OpenAPI schemas for custom `io-ts` codecs that can't be automatically derived
- Define OpenAPI schemas for custom `io-ts` codecs that can't be automatically derived.

Comment on lines 23 to 37
```json
// package.json of the external types package
{
"name": "my-external-types",
"version": "1.0.0",
"files": [
"dist/",
"src/" // Include source code
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"source": "src/index.ts" // Add this field
// ... rest of package.json
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this so it aligns with the numbering. I think 1 or 2 tabs.

Screenshot 2025-04-21 at 1 36 58 PM

describes the supported annotations for both endpoint definitions and schema
definitions.

## Endpoint annotations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Endpoint annotations
## Endpoint Annotations

});
```

### Supported OpenAPI tags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Supported OpenAPI tags
### Supported OpenAPI Tags

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

| JSDoc tag | OpenAPI property | Description |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| JSDoc tag | OpenAPI property | Description |
| JSDoc Tag | OpenAPI Property | Description |

| `@format <format>` | `format` | Format (e.g., `uuid`, `date-time`) |
| `@title <title>` | `title` | Schema title |

### Custom tags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Custom tags
### Custom Tags


### Custom tags

| JSDoc tag | OpenAPI property | Description |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| JSDoc tag | OpenAPI property | Description |
| JSDoc Tag | OpenAPI Property | Description |

@youngjungithub youngjungithub force-pushed the docs/refactor-openapi-generator-docs branch from eaf77a0 to 38b5681 Compare April 21, 2025 19:18
… format

This commit significantly refactors the documentation for the `@api-ts/openapi-generator` package to align with the Reference section principles of the Diátaxis framework. The goal is to provide users with a clear, structured, and authoritative technical description suitable for direct consultation during development.

**Key Changes:**

* Restructured the entire README.md into a dedicated Reference section, replacing the previous narrative format.
* Organized content into logical subsections for improved navigability and focus:
    * **Command-Line Interface (CLI):** Provides a technical overview, usage syntax, and detailed descriptions of the `<file>` argument, options (`--name`, `--version`, `--codec-file`), and flags (`--internal`, `--help`), along with concrete usage examples.
    * **Configuration:** Clearly documents the requirements for preparing external types packages (specifying `files` and `source` in the external package's `package.json`). Details the two distinct methods for defining custom codec schemas:
        1.  Via `openapi-gen.config.js` within the types package (recommended for type authors), including file naming, `package.json` requirements (`customCodecFile`, `files`), and file structure.
        2.  Via the `--codec-file` CLI option for consumers, specifying the required file structure (grouping by package name).
    * **Supported `io-ts` Primitives:** Includes a definitive list of `io-ts` primitives and combinators that the generator can automatically interpret to produce OpenAPI schemas.
    * **JSDoc Annotations:** Exhaustively documents the supported JSDoc tags used to enrich the generated OpenAPI specification, categorized by:
        * *Endpoint Annotations* (applied to `httpRoute` variables): Covers Summary, Description, `@operationId`, `@tag`, `@private`, `@unstable`, `@example`, and the handling of unknown tags (`x-unknown-tags`), explaining their direct mapping to OpenAPI Operation Object fields (like `summary`, `description`, `operationId`, `tags`, `x-internal`, `x-unstable`, `example`, `x-unknown-tags`).
        * *Schema Annotations* (applied to `io-ts` types/fields): Details how to add descriptions via JSDoc text and lists all supported standard OpenAPI tags (`@default`, `@example`, `@minLength`, `@maximum`, `@pattern`, `@format`, etc.) and custom tags (`@private`, `@deprecated`), explaining their effect on the resulting OpenAPI Schema Object or Property (like `description`, `default`, `minLength`, `deprecated`, `x-internal`). Includes comprehensive examples demonstrating tag usage.
* Removed introductory explanations and narrative prose, focusing strictly on factual, technical descriptions of the tool's features, configuration requirements, and behavior based on inputs (like JSDoc tags).

**Impact:**

This restructuring provides developers using `@api-ts/openapi-generator` with significantly improved technical reference documentation. The information is now presented in a consistent, predictable, and easily searchable format, adhering to the Diátaxis framework's guidelines for effective reference material. This makes it easier for users to find the specific technical details they need regarding CLI usage, configuration, supported types, and JSDoc annotation capabilities while working with the generator.

chore: apply feedback

chore: fix heading to use title casing
@youngjungithub youngjungithub force-pushed the docs/refactor-openapi-generator-docs branch from 035255a to 8046350 Compare April 22, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants