Skip to content

Commit 3af0977

Browse files
authored
Merge pull request #25 from qazsato/improve_search_suggestion_layout
Improve search suggestion layout
2 parents a8468c2 + aba6b4f commit 3af0977

5 files changed

Lines changed: 67 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node: [18, 20, 22]
15+
node: [20, 22, 24]
1616
name: Node ${{ matrix.node }} test
1717
steps:
1818
- uses: actions/checkout@v4

CLAUDE.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Development Commands
8+
- `npm run lint` - Run ESLint for code linting
9+
- `npm run lint:fix` - Run ESLint with automatic fixes
10+
- `npm run test` - Run Jest tests with experimental VM modules support
11+
12+
### Testing the CLI Tool
13+
- `npx openapi-generate-html -i openapi.json` - Generate HTML from OpenAPI spec
14+
- `npx openapi-generate-html -i openapi.json --theme=dark` - Generate with dark theme
15+
- `npx openapi-generate-html -i openapi.json --ui=swagger --output=custom.html` - Generate with Swagger UI
16+
17+
## Architecture
18+
19+
This is a Node.js CLI tool that generates standalone HTML documentation from OpenAPI specifications. The tool creates self-contained HTML files with all assets embedded.
20+
21+
### Core Components
22+
23+
**Main Entry Point (`src/index.js`)**
24+
- CLI argument parsing using Commander.js
25+
- Interactive prompts using Inquirer.js
26+
- Three-phase workflow: get options → render HTML → write file
27+
28+
**Template System (`resources/*/`)**
29+
- Three UI options: Stoplight Elements, Swagger UI, Redoc
30+
- Each UI has: `template.ejs`, `index.css`, `index.js`
31+
- Templates use EJS with embedded CSS/JS content and OpenAPI data
32+
33+
**Validation (`src/utils/validate.js`)**
34+
- Input validation for CLI commands and interactive prompts
35+
- Supports JSON/YAML files and URLs
36+
- Enforces HTML output format
37+
38+
**Constants (`src/constants/index.js`)**
39+
- UI types: `['stoplight', 'swagger', 'redoc']`
40+
- Themes: `['light', 'dark']`
41+
- File extensions: `['.json', '.yaml', '.yml']`
42+
43+
### Key Processing Steps
44+
45+
1. **Input Resolution**: Accepts file paths or URLs, validates format
46+
2. **$ref Resolution**: Uses `@apidevtools/json-schema-ref-parser` to bundle external references
47+
3. **Template Rendering**: EJS templates embed CSS, JS, and OpenAPI data into single HTML file
48+
4. **Output Generation**: Creates standalone HTML with no external dependencies
49+
50+
### File Structure Logic
51+
52+
- `src/index.js` - Main orchestration and rendering logic
53+
- `src/utils/validate.js` - All input validation functions
54+
- `src/constants/index.js` - Configuration constants
55+
- `resources/{ui}/` - UI-specific templates and assets
56+
- Tests are co-located with source files (e.g., `validate.test.js`)
57+
58+
### Testing
59+
60+
Uses Jest with ES modules (`--experimental-vm-modules` flag required). Tests focus on validation functions and CLI argument handling.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-generate-html",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"description": "Generate standalone HTML from OpenAPI Specification",
55
"type": "module",
66
"bin": {

resources/common/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
display: flex;
6262
flex-direction: column;
6363
flex: 1;
64+
word-break: break-all;
65+
overflow-wrap: break-word;
66+
white-space: normal;
6467
}
6568

6669
.endpoint-path {

0 commit comments

Comments
 (0)