nuxt-openapi-hyperfetch 0.2.7-alpha.1 โ 0.3.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +26 -26
- package/.prettierignore +17 -17
- package/CONTRIBUTING.md +291 -291
- package/INSTRUCTIONS.md +327 -327
- package/LICENSE +202 -202
- package/README.md +309 -231
- package/dist/cli/config.d.ts +9 -2
- package/dist/cli/config.js +1 -1
- package/dist/cli/logo.js +5 -5
- package/dist/cli/messages.d.ts +1 -0
- package/dist/cli/messages.js +2 -0
- package/dist/cli/prompts.d.ts +5 -0
- package/dist/cli/prompts.js +12 -0
- package/dist/cli/types.d.ts +1 -1
- package/dist/generators/components/connector-generator/templates.js +68 -19
- package/dist/generators/shared/runtime/useFormConnector.js +8 -1
- package/dist/generators/shared/runtime/useListConnector.js +13 -6
- package/dist/generators/use-async-data/generator.js +4 -0
- package/dist/generators/use-async-data/runtime/useApiAsyncData.js +4 -4
- package/dist/generators/use-async-data/runtime/useApiAsyncDataRaw.js +4 -4
- package/dist/generators/use-async-data/templates.js +17 -17
- package/dist/generators/use-fetch/generator.js +4 -0
- package/dist/generators/use-fetch/templates.js +14 -14
- package/dist/index.js +40 -27
- package/dist/module/index.js +19 -0
- package/dist/module/types.d.ts +7 -0
- package/docs/API-REFERENCE.md +886 -886
- package/docs/generated-components.md +615 -615
- package/docs/headless-composables-ui.md +569 -569
- package/eslint.config.js +85 -85
- package/package.json +1 -1
- package/src/cli/config.ts +147 -140
- package/src/cli/logger.ts +124 -124
- package/src/cli/logo.ts +25 -25
- package/src/cli/messages.ts +4 -0
- package/src/cli/prompts.ts +14 -1
- package/src/cli/types.ts +50 -50
- package/src/generators/components/connector-generator/generator.ts +138 -138
- package/src/generators/components/connector-generator/templates.ts +307 -254
- package/src/generators/components/connector-generator/types.ts +34 -34
- package/src/generators/components/schema-analyzer/index.ts +44 -44
- package/src/generators/components/schema-analyzer/intent-detector.ts +187 -187
- package/src/generators/components/schema-analyzer/openapi-reader.ts +96 -96
- package/src/generators/components/schema-analyzer/resource-grouper.ts +166 -166
- package/src/generators/components/schema-analyzer/schema-field-mapper.ts +268 -268
- package/src/generators/components/schema-analyzer/types.ts +177 -177
- package/src/generators/nuxt-server/generator.ts +272 -272
- package/src/generators/shared/runtime/apiHelpers.ts +535 -535
- package/src/generators/shared/runtime/pagination.ts +323 -323
- package/src/generators/shared/runtime/useDeleteConnector.ts +109 -109
- package/src/generators/shared/runtime/useDetailConnector.ts +64 -64
- package/src/generators/shared/runtime/useFormConnector.ts +147 -139
- package/src/generators/shared/runtime/useListConnector.ts +158 -148
- package/src/generators/shared/runtime/zod-error-merger.ts +119 -119
- package/src/generators/shared/templates/api-callbacks-plugin.ts +399 -399
- package/src/generators/shared/templates/api-pagination-plugin.ts +158 -158
- package/src/generators/use-async-data/generator.ts +213 -205
- package/src/generators/use-async-data/runtime/useApiAsyncData.ts +329 -329
- package/src/generators/use-async-data/runtime/useApiAsyncDataRaw.ts +324 -324
- package/src/generators/use-async-data/templates.ts +257 -257
- package/src/generators/use-fetch/generator.ts +178 -170
- package/src/generators/use-fetch/runtime/useApiRequest.ts +354 -354
- package/src/generators/use-fetch/templates.ts +214 -214
- package/src/index.ts +306 -303
- package/src/module/index.ts +158 -133
- package/src/module/types.ts +39 -31
- package/dist/generators/tanstack-query/generator.d.ts +0 -5
- package/dist/generators/tanstack-query/generator.js +0 -11
package/.editorconfig
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
-
|
|
3
|
-
# Top-most EditorConfig file
|
|
4
|
-
root = true
|
|
5
|
-
|
|
6
|
-
# Unix-style newlines with a newline ending every file
|
|
7
|
-
[*]
|
|
8
|
-
charset = utf-8
|
|
9
|
-
end_of_line = lf
|
|
10
|
-
insert_final_newline = true
|
|
11
|
-
trim_trailing_whitespace = true
|
|
12
|
-
|
|
13
|
-
# TypeScript, JavaScript, JSON
|
|
14
|
-
[*.{ts,js,json}]
|
|
15
|
-
indent_style = space
|
|
16
|
-
indent_size = 2
|
|
17
|
-
|
|
18
|
-
# Markdown
|
|
19
|
-
[*.md]
|
|
20
|
-
trim_trailing_whitespace = false
|
|
21
|
-
indent_size = 2
|
|
22
|
-
|
|
23
|
-
# YAML
|
|
24
|
-
[*.{yml,yaml}]
|
|
25
|
-
indent_style = space
|
|
26
|
-
indent_size = 2
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# Top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# Unix-style newlines with a newline ending every file
|
|
7
|
+
[*]
|
|
8
|
+
charset = utf-8
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
insert_final_newline = true
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
|
|
13
|
+
# TypeScript, JavaScript, JSON
|
|
14
|
+
[*.{ts,js,json}]
|
|
15
|
+
indent_style = space
|
|
16
|
+
indent_size = 2
|
|
17
|
+
|
|
18
|
+
# Markdown
|
|
19
|
+
[*.md]
|
|
20
|
+
trim_trailing_whitespace = false
|
|
21
|
+
indent_size = 2
|
|
22
|
+
|
|
23
|
+
# YAML
|
|
24
|
+
[*.{yml,yaml}]
|
|
25
|
+
indent_style = space
|
|
26
|
+
indent_size = 2
|
package/.prettierignore
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
|
|
4
|
-
# Build output
|
|
5
|
-
dist/
|
|
6
|
-
|
|
7
|
-
# Generated files
|
|
8
|
-
swagger/
|
|
9
|
-
test-*/
|
|
10
|
-
|
|
11
|
-
# Lock files
|
|
12
|
-
package-lock.json
|
|
13
|
-
pnpm-lock.yaml
|
|
14
|
-
yarn.lock
|
|
15
|
-
|
|
16
|
-
# CHANGELOG
|
|
17
|
-
CHANGELOG.md
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build output
|
|
5
|
+
dist/
|
|
6
|
+
|
|
7
|
+
# Generated files
|
|
8
|
+
swagger/
|
|
9
|
+
test-*/
|
|
10
|
+
|
|
11
|
+
# Lock files
|
|
12
|
+
package-lock.json
|
|
13
|
+
pnpm-lock.yaml
|
|
14
|
+
yarn.lock
|
|
15
|
+
|
|
16
|
+
# CHANGELOG
|
|
17
|
+
CHANGELOG.md
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
# Contributing to Nuxt Generator
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to Nuxt Generator! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
-
|
|
5
|
-
## ๐ Prerequisites
|
|
6
|
-
|
|
7
|
-
- **Node.js** >= 18.x
|
|
8
|
-
- **npm** >= 9.x
|
|
9
|
-
- **Git**
|
|
10
|
-
|
|
11
|
-
## ๐ Before You Start - Read the Documentation
|
|
12
|
-
|
|
13
|
-
Before contributing, we highly recommend reading the technical documentation in the `docs/` directory:
|
|
14
|
-
|
|
15
|
-
### Essential Reading
|
|
16
|
-
|
|
17
|
-
1. **[Quick Start Guide](./docs/QUICK-START.md)** - Understand the project structure and core concepts
|
|
18
|
-
- Project overview and architecture
|
|
19
|
-
- Key files and their purposes
|
|
20
|
-
- Most common tasks
|
|
21
|
-
|
|
22
|
-
2. **[Architecture Documentation](./docs/ARCHITECTURE.md)** - Understand design decisions
|
|
23
|
-
- Why the codebase is structured this way
|
|
24
|
-
- Core patterns (two-stage generation, wrapper pattern, shared code)
|
|
25
|
-
- Design decisions (ADRs) with trade-offs explained
|
|
26
|
-
|
|
27
|
-
3. **[Development Guide](./docs/DEVELOPMENT.md)** - Practical development instructions
|
|
28
|
-
- How to add features (new callbacks, generators, parser features)
|
|
29
|
-
- Testing strategies
|
|
30
|
-
- Code style guidelines
|
|
31
|
-
- Debugging tips
|
|
32
|
-
|
|
33
|
-
4. **[API Reference](./docs/API-REFERENCE.md)** - Complete technical reference
|
|
34
|
-
- All interfaces and types
|
|
35
|
-
- Parser, template, and runtime APIs
|
|
36
|
-
- Callback system documentation
|
|
37
|
-
|
|
38
|
-
### Quick Reference
|
|
39
|
-
|
|
40
|
-
- Adding a new callback type? โ See [Development Guide - Add a New Callback](./docs/DEVELOPMENT.md#add-a-new-callback-type)
|
|
41
|
-
- Adding a new generator? โ See [Development Guide - Add a New Generator](./docs/DEVELOPMENT.md#add-a-new-generator-type)
|
|
42
|
-
- Parser not working? โ See [Troubleshooting Guide](./docs/TROUBLESHOOTING.md#parser-not-finding-methods)
|
|
43
|
-
- Understanding global callbacks? โ See [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive)
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## ๐ Getting Started
|
|
48
|
-
|
|
49
|
-
### 1. Fork and Clone
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# Fork the repository on GitHub, then clone your fork
|
|
53
|
-
git clone https://github.com/dmartindiaz/nuxt-openapi-hyperfetch.git
|
|
54
|
-
cd nuxt-openapi-hyperfetch
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 2. Install Dependencies
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npm install
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 3. Build the Project
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npm run build
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## ๐ ๏ธ Development Workflow
|
|
70
|
-
|
|
71
|
-
### Available Scripts
|
|
72
|
-
|
|
73
|
-
| Script | Description |
|
|
74
|
-
| ---------------------- | ------------------------------------------------------- |
|
|
75
|
-
| `npm run build` | Compile TypeScript to JavaScript |
|
|
76
|
-
| `npm run start` | Build and run the CLI |
|
|
77
|
-
| `npm run lint` | Check code for linting errors |
|
|
78
|
-
| `npm run lint:fix` | Automatically fix linting errors |
|
|
79
|
-
| `npm run format` | Format all code with Prettier |
|
|
80
|
-
| `npm run format:check` | Check if code is formatted correctly |
|
|
81
|
-
| `npm run type-check` | Run TypeScript type checking without building |
|
|
82
|
-
| `npm run validate` | Run type-check + lint + format-check (pre-commit check) |
|
|
83
|
-
|
|
84
|
-
### Before Committing
|
|
85
|
-
|
|
86
|
-
**Always run these commands before committing:**
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# Format code
|
|
90
|
-
npm run format
|
|
91
|
-
|
|
92
|
-
# Fix linting issues
|
|
93
|
-
npm run lint:fix
|
|
94
|
-
|
|
95
|
-
# Validate everything
|
|
96
|
-
npm run validate
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Code Style
|
|
100
|
-
|
|
101
|
-
We use **ESLint** and **Prettier** to maintain consistent code style across the project.
|
|
102
|
-
|
|
103
|
-
#### ESLint Rules
|
|
104
|
-
|
|
105
|
-
- **TypeScript strict mode** - All code must pass type checking
|
|
106
|
-
- **No unused variables** - Prefix with `_` if intentionally unused
|
|
107
|
-
- **Prefer const** - Use `const` over `let` when possible
|
|
108
|
-
- **No var** - Always use `const` or `let`
|
|
109
|
-
- **Explicit return types** - Recommended but not enforced
|
|
110
|
-
|
|
111
|
-
#### Prettier Configuration
|
|
112
|
-
|
|
113
|
-
- **Single quotes** - Use `'` instead of `"`
|
|
114
|
-
- **Semicolons** - Always use semicolons
|
|
115
|
-
- **Trailing commas** - ES5 style (objects, arrays)
|
|
116
|
-
- **Print width** - 100 characters
|
|
117
|
-
- **Tab width** - 2 spaces
|
|
118
|
-
- **Line endings** - LF (Unix style)
|
|
119
|
-
|
|
120
|
-
### EditorConfig
|
|
121
|
-
|
|
122
|
-
The project includes an `.editorconfig` file. Make sure your editor supports EditorConfig:
|
|
123
|
-
|
|
124
|
-
- **VS Code**: Install "EditorConfig for VS Code" extension
|
|
125
|
-
- **WebStorm/IntelliJ**: Built-in support
|
|
126
|
-
- **Sublime**: Install "EditorConfig" package
|
|
127
|
-
- **Vim**: Install "editorconfig-vim" plugin
|
|
128
|
-
|
|
129
|
-
## ๐ Pull Request Process
|
|
130
|
-
|
|
131
|
-
### 1. Create a Feature Branch
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
git checkout -b feature/your-feature-name
|
|
135
|
-
# or
|
|
136
|
-
git checkout -b fix/your-bugfix-name
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### 2. Make Your Changes
|
|
140
|
-
|
|
141
|
-
- Write clean, readable code
|
|
142
|
-
- Follow existing code patterns
|
|
143
|
-
- Add comments for complex logic
|
|
144
|
-
- Update documentation if needed
|
|
145
|
-
|
|
146
|
-
### 3. Test Your Changes
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# Build the project
|
|
150
|
-
npm run build
|
|
151
|
-
|
|
152
|
-
# Test generation with example
|
|
153
|
-
npm run generator
|
|
154
|
-
|
|
155
|
-
# Or test with specific swagger file
|
|
156
|
-
node dist/index.js generate -i swagger.yaml -o ./test-output
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### 4. Validate Your Code
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Run all checks
|
|
163
|
-
npm run validate
|
|
164
|
-
|
|
165
|
-
# This runs:
|
|
166
|
-
# - TypeScript type checking
|
|
167
|
-
# - ESLint
|
|
168
|
-
# - Prettier format check
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 5. Commit Your Changes
|
|
172
|
-
|
|
173
|
-
Use clear, descriptive commit messages:
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
# Good commit messages
|
|
177
|
-
git commit -m "feat: add support for x generator"
|
|
178
|
-
git commit -m "fix: resolve path issues on Windows"
|
|
179
|
-
git commit -m "docs: update README with global callbacks examples"
|
|
180
|
-
git commit -m "refactor: extract common parser logic to shared module"
|
|
181
|
-
|
|
182
|
-
# Follow conventional commits format
|
|
183
|
-
# <type>: <description>
|
|
184
|
-
# Types: feat, fix, docs, style, refactor, test, chore
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 6. Push and Create PR
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
git push origin feature/your-feature-name
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Then create a Pull Request on GitHub with:
|
|
194
|
-
|
|
195
|
-
- **Clear title** - What does this PR do?
|
|
196
|
-
- **Description** - Why is this change needed?
|
|
197
|
-
- **Testing** - How did you test it?
|
|
198
|
-
- **Screenshots** - If applicable
|
|
199
|
-
|
|
200
|
-
## ๐ Reporting Bugs
|
|
201
|
-
|
|
202
|
-
When reporting bugs, please include:
|
|
203
|
-
|
|
204
|
-
1. **Description** - Clear description of the bug
|
|
205
|
-
2. **Steps to reproduce** - Minimal steps to reproduce the issue
|
|
206
|
-
3. **Expected behavior** - What you expected to happen
|
|
207
|
-
4. **Actual behavior** - What actually happened
|
|
208
|
-
5. **Environment**:
|
|
209
|
-
- Node.js version: `node --version`
|
|
210
|
-
- npm version: `npm --version`
|
|
211
|
-
- OS: Windows/Mac/Linux
|
|
212
|
-
6. **Swagger file** - If possible, provide the OpenAPI/Swagger file that causes the issue
|
|
213
|
-
|
|
214
|
-
## ๐ก Suggesting Features
|
|
215
|
-
|
|
216
|
-
Feature requests are welcome! Please include:
|
|
217
|
-
|
|
218
|
-
1. **Use case** - What problem does this solve?
|
|
219
|
-
2. **Proposed solution** - How should it work?
|
|
220
|
-
3. **Alternatives** - Have you considered other approaches?
|
|
221
|
-
4. **Examples** - Code examples if applicable
|
|
222
|
-
|
|
223
|
-
## ๐ Project Structure
|
|
224
|
-
|
|
225
|
-
```
|
|
226
|
-
nuxt-generator/
|
|
227
|
-
โโโ src/
|
|
228
|
-
โ โโโ index.ts # CLI entry point
|
|
229
|
-
โ โโโ generate.ts # OpenAPI generator wrapper
|
|
230
|
-
โ โโโ cli/ # CLI utilities (prompts, logger, logo)
|
|
231
|
-
โ โโโ generators/
|
|
232
|
-
โ โโโ shared/ # Shared types and runtime helpers
|
|
233
|
-
โ โโโ use-fetch/ # useFetch generator
|
|
234
|
-
โ โโโ use-async-data/ # useAsyncData generator
|
|
235
|
-
โ โโโ nuxt-server/ # Nuxt Server Routes generator
|
|
236
|
-
โโโ dist/ # Compiled output
|
|
237
|
-
โโโ eslint.config.js # ESLint configuration
|
|
238
|
-
โโโ .prettierrc.json # Prettier configuration
|
|
239
|
-
โโโ .editorconfig # Editor configuration
|
|
240
|
-
โโโ tsconfig.json # TypeScript configuration
|
|
241
|
-
โโโ INSTRUCTIONS.md # Detailed technical documentation
|
|
242
|
-
โโโ README.md # User documentation
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
## ๐งช Testing
|
|
246
|
-
|
|
247
|
-
### Manual Testing
|
|
248
|
-
|
|
249
|
-
1. Generate composables from example swagger.yaml:
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
npm run generator
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
2. Test different generators:
|
|
256
|
-
|
|
257
|
-
```bash
|
|
258
|
-
# useFetch
|
|
259
|
-
echo useFetch | npm run generator
|
|
260
|
-
|
|
261
|
-
# useAsyncData
|
|
262
|
-
echo useAsyncData | npm run generator
|
|
263
|
-
|
|
264
|
-
# Nuxt Server Routes
|
|
265
|
-
echo nuxtServer | npm run generator
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
3. Verify generated code compiles in a Nuxt project
|
|
269
|
-
|
|
270
|
-
### Future: Automated Tests
|
|
271
|
-
|
|
272
|
-
We plan to add automated tests in the future. Contributions welcome!
|
|
273
|
-
|
|
274
|
-
## โ Questions?
|
|
275
|
-
|
|
276
|
-
- **Documentation**: Read the comprehensive docs in the `docs/` directory:
|
|
277
|
-
- [Quick Start](./docs/QUICK-START.md) - Project overview and core concepts
|
|
278
|
-
- [Architecture](./docs/ARCHITECTURE.md) - Design patterns and decisions
|
|
279
|
-
- [Development Guide](./docs/DEVELOPMENT.md) - How to extend and contribute
|
|
280
|
-
- [API Reference](./docs/API-REFERENCE.md) - Complete technical reference
|
|
281
|
-
- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
|
|
282
|
-
- **Issues**: Search [existing issues](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues)
|
|
283
|
-
- **Discussions**: Start a [discussion](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/discussions)
|
|
284
|
-
|
|
285
|
-
## ๐ License
|
|
286
|
-
|
|
287
|
-
By contributing, you agree that your contributions will be licensed under the Apache-2.0 License.
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
**Happy coding! ๐**
|
|
1
|
+
# Contributing to Nuxt Generator
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Nuxt Generator! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## ๐ Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Node.js** >= 18.x
|
|
8
|
+
- **npm** >= 9.x
|
|
9
|
+
- **Git**
|
|
10
|
+
|
|
11
|
+
## ๐ Before You Start - Read the Documentation
|
|
12
|
+
|
|
13
|
+
Before contributing, we highly recommend reading the technical documentation in the `docs/` directory:
|
|
14
|
+
|
|
15
|
+
### Essential Reading
|
|
16
|
+
|
|
17
|
+
1. **[Quick Start Guide](./docs/QUICK-START.md)** - Understand the project structure and core concepts
|
|
18
|
+
- Project overview and architecture
|
|
19
|
+
- Key files and their purposes
|
|
20
|
+
- Most common tasks
|
|
21
|
+
|
|
22
|
+
2. **[Architecture Documentation](./docs/ARCHITECTURE.md)** - Understand design decisions
|
|
23
|
+
- Why the codebase is structured this way
|
|
24
|
+
- Core patterns (two-stage generation, wrapper pattern, shared code)
|
|
25
|
+
- Design decisions (ADRs) with trade-offs explained
|
|
26
|
+
|
|
27
|
+
3. **[Development Guide](./docs/DEVELOPMENT.md)** - Practical development instructions
|
|
28
|
+
- How to add features (new callbacks, generators, parser features)
|
|
29
|
+
- Testing strategies
|
|
30
|
+
- Code style guidelines
|
|
31
|
+
- Debugging tips
|
|
32
|
+
|
|
33
|
+
4. **[API Reference](./docs/API-REFERENCE.md)** - Complete technical reference
|
|
34
|
+
- All interfaces and types
|
|
35
|
+
- Parser, template, and runtime APIs
|
|
36
|
+
- Callback system documentation
|
|
37
|
+
|
|
38
|
+
### Quick Reference
|
|
39
|
+
|
|
40
|
+
- Adding a new callback type? โ See [Development Guide - Add a New Callback](./docs/DEVELOPMENT.md#add-a-new-callback-type)
|
|
41
|
+
- Adding a new generator? โ See [Development Guide - Add a New Generator](./docs/DEVELOPMENT.md#add-a-new-generator-type)
|
|
42
|
+
- Parser not working? โ See [Troubleshooting Guide](./docs/TROUBLESHOOTING.md#parser-not-finding-methods)
|
|
43
|
+
- Understanding global callbacks? โ See [Architecture - Global Callbacks](./docs/ARCHITECTURE.md#global-callbacks-deep-dive)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ๐ Getting Started
|
|
48
|
+
|
|
49
|
+
### 1. Fork and Clone
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Fork the repository on GitHub, then clone your fork
|
|
53
|
+
git clone https://github.com/dmartindiaz/nuxt-openapi-hyperfetch.git
|
|
54
|
+
cd nuxt-openapi-hyperfetch
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 2. Install Dependencies
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Build the Project
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm run build
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ๐ ๏ธ Development Workflow
|
|
70
|
+
|
|
71
|
+
### Available Scripts
|
|
72
|
+
|
|
73
|
+
| Script | Description |
|
|
74
|
+
| ---------------------- | ------------------------------------------------------- |
|
|
75
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
76
|
+
| `npm run start` | Build and run the CLI |
|
|
77
|
+
| `npm run lint` | Check code for linting errors |
|
|
78
|
+
| `npm run lint:fix` | Automatically fix linting errors |
|
|
79
|
+
| `npm run format` | Format all code with Prettier |
|
|
80
|
+
| `npm run format:check` | Check if code is formatted correctly |
|
|
81
|
+
| `npm run type-check` | Run TypeScript type checking without building |
|
|
82
|
+
| `npm run validate` | Run type-check + lint + format-check (pre-commit check) |
|
|
83
|
+
|
|
84
|
+
### Before Committing
|
|
85
|
+
|
|
86
|
+
**Always run these commands before committing:**
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Format code
|
|
90
|
+
npm run format
|
|
91
|
+
|
|
92
|
+
# Fix linting issues
|
|
93
|
+
npm run lint:fix
|
|
94
|
+
|
|
95
|
+
# Validate everything
|
|
96
|
+
npm run validate
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Code Style
|
|
100
|
+
|
|
101
|
+
We use **ESLint** and **Prettier** to maintain consistent code style across the project.
|
|
102
|
+
|
|
103
|
+
#### ESLint Rules
|
|
104
|
+
|
|
105
|
+
- **TypeScript strict mode** - All code must pass type checking
|
|
106
|
+
- **No unused variables** - Prefix with `_` if intentionally unused
|
|
107
|
+
- **Prefer const** - Use `const` over `let` when possible
|
|
108
|
+
- **No var** - Always use `const` or `let`
|
|
109
|
+
- **Explicit return types** - Recommended but not enforced
|
|
110
|
+
|
|
111
|
+
#### Prettier Configuration
|
|
112
|
+
|
|
113
|
+
- **Single quotes** - Use `'` instead of `"`
|
|
114
|
+
- **Semicolons** - Always use semicolons
|
|
115
|
+
- **Trailing commas** - ES5 style (objects, arrays)
|
|
116
|
+
- **Print width** - 100 characters
|
|
117
|
+
- **Tab width** - 2 spaces
|
|
118
|
+
- **Line endings** - LF (Unix style)
|
|
119
|
+
|
|
120
|
+
### EditorConfig
|
|
121
|
+
|
|
122
|
+
The project includes an `.editorconfig` file. Make sure your editor supports EditorConfig:
|
|
123
|
+
|
|
124
|
+
- **VS Code**: Install "EditorConfig for VS Code" extension
|
|
125
|
+
- **WebStorm/IntelliJ**: Built-in support
|
|
126
|
+
- **Sublime**: Install "EditorConfig" package
|
|
127
|
+
- **Vim**: Install "editorconfig-vim" plugin
|
|
128
|
+
|
|
129
|
+
## ๐ Pull Request Process
|
|
130
|
+
|
|
131
|
+
### 1. Create a Feature Branch
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git checkout -b feature/your-feature-name
|
|
135
|
+
# or
|
|
136
|
+
git checkout -b fix/your-bugfix-name
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2. Make Your Changes
|
|
140
|
+
|
|
141
|
+
- Write clean, readable code
|
|
142
|
+
- Follow existing code patterns
|
|
143
|
+
- Add comments for complex logic
|
|
144
|
+
- Update documentation if needed
|
|
145
|
+
|
|
146
|
+
### 3. Test Your Changes
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Build the project
|
|
150
|
+
npm run build
|
|
151
|
+
|
|
152
|
+
# Test generation with example
|
|
153
|
+
npm run generator
|
|
154
|
+
|
|
155
|
+
# Or test with specific swagger file
|
|
156
|
+
node dist/index.js generate -i swagger.yaml -o ./test-output
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 4. Validate Your Code
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Run all checks
|
|
163
|
+
npm run validate
|
|
164
|
+
|
|
165
|
+
# This runs:
|
|
166
|
+
# - TypeScript type checking
|
|
167
|
+
# - ESLint
|
|
168
|
+
# - Prettier format check
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 5. Commit Your Changes
|
|
172
|
+
|
|
173
|
+
Use clear, descriptive commit messages:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Good commit messages
|
|
177
|
+
git commit -m "feat: add support for x generator"
|
|
178
|
+
git commit -m "fix: resolve path issues on Windows"
|
|
179
|
+
git commit -m "docs: update README with global callbacks examples"
|
|
180
|
+
git commit -m "refactor: extract common parser logic to shared module"
|
|
181
|
+
|
|
182
|
+
# Follow conventional commits format
|
|
183
|
+
# <type>: <description>
|
|
184
|
+
# Types: feat, fix, docs, style, refactor, test, chore
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 6. Push and Create PR
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
git push origin feature/your-feature-name
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Then create a Pull Request on GitHub with:
|
|
194
|
+
|
|
195
|
+
- **Clear title** - What does this PR do?
|
|
196
|
+
- **Description** - Why is this change needed?
|
|
197
|
+
- **Testing** - How did you test it?
|
|
198
|
+
- **Screenshots** - If applicable
|
|
199
|
+
|
|
200
|
+
## ๐ Reporting Bugs
|
|
201
|
+
|
|
202
|
+
When reporting bugs, please include:
|
|
203
|
+
|
|
204
|
+
1. **Description** - Clear description of the bug
|
|
205
|
+
2. **Steps to reproduce** - Minimal steps to reproduce the issue
|
|
206
|
+
3. **Expected behavior** - What you expected to happen
|
|
207
|
+
4. **Actual behavior** - What actually happened
|
|
208
|
+
5. **Environment**:
|
|
209
|
+
- Node.js version: `node --version`
|
|
210
|
+
- npm version: `npm --version`
|
|
211
|
+
- OS: Windows/Mac/Linux
|
|
212
|
+
6. **Swagger file** - If possible, provide the OpenAPI/Swagger file that causes the issue
|
|
213
|
+
|
|
214
|
+
## ๐ก Suggesting Features
|
|
215
|
+
|
|
216
|
+
Feature requests are welcome! Please include:
|
|
217
|
+
|
|
218
|
+
1. **Use case** - What problem does this solve?
|
|
219
|
+
2. **Proposed solution** - How should it work?
|
|
220
|
+
3. **Alternatives** - Have you considered other approaches?
|
|
221
|
+
4. **Examples** - Code examples if applicable
|
|
222
|
+
|
|
223
|
+
## ๐ Project Structure
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
nuxt-generator/
|
|
227
|
+
โโโ src/
|
|
228
|
+
โ โโโ index.ts # CLI entry point
|
|
229
|
+
โ โโโ generate.ts # OpenAPI generator wrapper
|
|
230
|
+
โ โโโ cli/ # CLI utilities (prompts, logger, logo)
|
|
231
|
+
โ โโโ generators/
|
|
232
|
+
โ โโโ shared/ # Shared types and runtime helpers
|
|
233
|
+
โ โโโ use-fetch/ # useFetch generator
|
|
234
|
+
โ โโโ use-async-data/ # useAsyncData generator
|
|
235
|
+
โ โโโ nuxt-server/ # Nuxt Server Routes generator
|
|
236
|
+
โโโ dist/ # Compiled output
|
|
237
|
+
โโโ eslint.config.js # ESLint configuration
|
|
238
|
+
โโโ .prettierrc.json # Prettier configuration
|
|
239
|
+
โโโ .editorconfig # Editor configuration
|
|
240
|
+
โโโ tsconfig.json # TypeScript configuration
|
|
241
|
+
โโโ INSTRUCTIONS.md # Detailed technical documentation
|
|
242
|
+
โโโ README.md # User documentation
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## ๐งช Testing
|
|
246
|
+
|
|
247
|
+
### Manual Testing
|
|
248
|
+
|
|
249
|
+
1. Generate composables from example swagger.yaml:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
npm run generator
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
2. Test different generators:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# useFetch
|
|
259
|
+
echo useFetch | npm run generator
|
|
260
|
+
|
|
261
|
+
# useAsyncData
|
|
262
|
+
echo useAsyncData | npm run generator
|
|
263
|
+
|
|
264
|
+
# Nuxt Server Routes
|
|
265
|
+
echo nuxtServer | npm run generator
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
3. Verify generated code compiles in a Nuxt project
|
|
269
|
+
|
|
270
|
+
### Future: Automated Tests
|
|
271
|
+
|
|
272
|
+
We plan to add automated tests in the future. Contributions welcome!
|
|
273
|
+
|
|
274
|
+
## โ Questions?
|
|
275
|
+
|
|
276
|
+
- **Documentation**: Read the comprehensive docs in the `docs/` directory:
|
|
277
|
+
- [Quick Start](./docs/QUICK-START.md) - Project overview and core concepts
|
|
278
|
+
- [Architecture](./docs/ARCHITECTURE.md) - Design patterns and decisions
|
|
279
|
+
- [Development Guide](./docs/DEVELOPMENT.md) - How to extend and contribute
|
|
280
|
+
- [API Reference](./docs/API-REFERENCE.md) - Complete technical reference
|
|
281
|
+
- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
|
|
282
|
+
- **Issues**: Search [existing issues](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/issues)
|
|
283
|
+
- **Discussions**: Start a [discussion](https://github.com/dmartindiaz/nuxt-openapi-hyperfetch/discussions)
|
|
284
|
+
|
|
285
|
+
## ๐ License
|
|
286
|
+
|
|
287
|
+
By contributing, you agree that your contributions will be licensed under the Apache-2.0 License.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
**Happy coding! ๐**
|