@ng-openapi/zod 0.0.2-pr-26-feature-zod-d67a0ae.0

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.
Files changed (6) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +118 -0
  3. package/index.cjs +3573 -0
  4. package/index.d.ts +191 -0
  5. package/index.js +3538 -0
  6. package/package.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tareq Jami
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ <div align="center">
2
+ <h1 align="center"><img src="https://raw.githubusercontent.com/ng-openapi/ng-openapi/HEAD/docs/public/ng-openapi-logo.svg" alt="Logo" style="height: 12vh; margin-bottom: 2vh;" width="160"></h1>
3
+ <h1 align="center"><b>Zod Plugin</b></h1>
4
+ <p align="center">πŸš€ Zod schema generator plugin for <a href="https://www.npmjs.com/package/ng-openapi">ng-openapi</a></p>
5
+ </div>
6
+
7
+ <p align="center">
8
+ <a href="https://stackblitz.com/@Mr-Jami/collections/ng-openapi-examples">⚑Examples</a>
9
+ <span>&nbsp;β€’&nbsp;</span>
10
+ <a href="https://ng-openapi.dev/">πŸ“Documentation</a>
11
+ <span>&nbsp;β€’&nbsp;</span>
12
+ <a href="https://github.com/ng-openapi/ng-openapi/issues">πŸ›Issues</a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@ng-openapi/zod" rel="nofollow"><img src="https://img.shields.io/npm/v/@ng-openapi/zod.svg" alt="npm version"></a>
17
+ <a href="https://opensource.org/license/mit" rel="nofollow"><img src="https://img.shields.io/github/license/ng-openapi/ng-openapi" alt="MIT License"></a>
18
+ <a href="https://github.com/ng-openapi/ng-openapi/actions?query=branch%3Amain"><img src="https://img.shields.io/github/last-commit/ng-openapi/ng-openapi" alt="Last commit" /></a>
19
+ <a href="https://github.com/ng-openapi/ng-openapi/actions?query=branch%3Amain"><img src="https://github.com/ng-openapi/ng-openapi/actions/workflows/release.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
20
+ </p>
21
+ <br/>
22
+
23
+ ## What is Zod Plugin?
24
+
25
+ tbd.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @ng-openapi/zod ng-openapi --save-dev
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### 1. Configure Plugin
36
+
37
+ ```typescript
38
+ // openapi.config.ts
39
+ import { GeneratorConfig } from 'ng-openapi';
40
+ import { HttpResourcePlugin } from '@ng-openapi/zod';
41
+
42
+ export default {
43
+ input: './swagger.json',
44
+ output: './src/api',
45
+ clientName: 'NgOpenApi',
46
+ plugins: [HttpResourcePlugin],
47
+ } as GeneratorConfig;
48
+ ```
49
+
50
+ ### 2. Generate Resources
51
+
52
+ ```bash
53
+ ng-openapi -c openapi.config.ts
54
+ ```
55
+
56
+ ### 3. Setup Providers
57
+
58
+ ```typescript
59
+ // app.config.ts
60
+ import { ApplicationConfig } from '@angular/core';
61
+ import { provideDefaultClient } from './api/providers';
62
+
63
+ export const appConfig: ApplicationConfig = {
64
+ providers: [
65
+ provideNgOpenApiClient({
66
+ basePath: 'https://api.example.com'
67
+ })
68
+ ]
69
+ };
70
+ ```
71
+
72
+ ### 4. Use Generated Resources
73
+
74
+ ```typescript
75
+ import { Component, inject } from '@angular/core';
76
+ import { UsersResource } from './api/resources';
77
+
78
+ @Component({
79
+ selector: 'app-users',
80
+ template: `
81
+ <div>
82
+ @if (users.isLoading()) {
83
+ <p>Loading...</p>
84
+ }
85
+ @if (users.error()) {
86
+ <p>Error: {{ users.error() }}</p>
87
+ }
88
+ @for (user of users.value(); track user.id) {
89
+ <div>{{ user.name }}</div>
90
+ }
91
+ </div>
92
+ `
93
+ })
94
+ export class UsersComponent {
95
+ private readonly usersResource = inject(UsersResource);
96
+
97
+ // Automatic caching and reactive updates
98
+ readonly users = this.usersResource.getUsers();
99
+ }
100
+ ```
101
+
102
+ ## Generated Structure
103
+
104
+ ```
105
+ src/api/
106
+ β”œβ”€β”€ models/ # TypeScript interfaces
107
+ β”œβ”€β”€ resources/ # HTTP Resource services
108
+ β”‚ β”œβ”€β”€ index.ts # Resource exports
109
+ β”‚ └── *.resource.ts # Generated resources
110
+ β”œβ”€β”€ services/ # Traditional HttpClient services
111
+ β”œβ”€β”€ providers.ts # Provider functions
112
+ └── index.ts # Main exports
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ - πŸ“– [Full Documentation](https://ng-openapi.dev/plugins/zod)
118
+ - πŸš€ [Live Examples](https://stackblitz.com/@Mr-Jami/collections/ng-openapi-examples)