You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`statuses-internal.tsp`| POST (write) | Internal adapters | ❌ No (opt-in) |
112
+
113
+
**Why the split?**
114
+
-**External clients** (UI, CLI, monitoring) only need to read status information
115
+
-**Internal adapters** (validator, provisioner, dns) need to write/update status reports
116
+
- Separating these allows generating different API contracts for different audiences
117
+
104
118
105
119
## Prerequisites
106
120
@@ -137,23 +151,53 @@ This installs all required TypeSpec libraries to the local `node_modules/` direc
137
151
138
152
The repository uses a single `main.tsp` entry point. To generate either the core API or GCP API, you need to re-link the `aliases.tsp` file to point to the desired provider aliases file.
139
153
140
-
### Using the Build Script (Recommended)
154
+
### Output Formats
155
+
156
+
The build system supports two OpenAPI formats:
157
+
-**OpenAPI 3.0** (default) - Modern format with full feature support
158
+
-**OpenAPI 2.0 (Swagger)** - Legacy format for compatibility with older tools
141
159
142
-
The easiest way to build the OpenAPI schema is using the provided `build-schema.sh` script:
160
+
### Using npm Scripts (Recommended)
161
+
162
+
The easiest way to build the OpenAPI schema is using the provided npm scripts:
143
163
144
164
```bash
145
-
# Build Core API
146
-
./build-schema.sh core
165
+
# Build OpenAPI 3.0 only
166
+
npm run build:core # Build Core API (OpenAPI 3.0)
167
+
npm run build:gcp # Build GCP API (OpenAPI 3.0)
168
+
169
+
# Build both OpenAPI 3.0 and OpenAPI 2.0 (Swagger)
170
+
npm run build:core:swagger # Build Core API with Swagger
171
+
npm run build:gcp:swagger # Build GCP API with Swagger
172
+
173
+
# Build all providers with both formats
174
+
npm run build:all
175
+
```
147
176
148
-
# Build GCP API
177
+
### Using the Build Script Directly
178
+
179
+
You can also use the `build-schema.sh` script directly:
180
+
181
+
```bash
182
+
# Build OpenAPI 3.0 only
183
+
./build-schema.sh core
149
184
./build-schema.sh gcp
185
+
186
+
# Build with OpenAPI 2.0 (Swagger) output
187
+
./build-schema.sh core --swagger
188
+
./build-schema.sh gcp --swagger
189
+
# or use the alias:
190
+
./build-schema.sh gcp --openapi2
150
191
```
151
192
152
193
The script automatically:
153
194
1. Validates the provider parameter
154
195
2. Re-links `aliases.tsp` to the appropriate provider aliases file
155
-
3. Compiles the TypeSpec to generate the OpenAPI schema
156
-
4. Outputs the result to `schemas/{provider}/openapi.yaml` (e.g., `schemas/core/openapi.yaml` or `schemas/gcp/openapi.yaml`)
196
+
3. Compiles the TypeSpec to generate the OpenAPI 3.0 schema
197
+
4. (If `--swagger` flag is used) Converts OpenAPI 3.0 to OpenAPI 2.0 (Swagger)
198
+
5. Outputs the results to `schemas/{provider}/`:
199
+
-`openapi.yaml` - OpenAPI 3.0 specification
200
+
-`swagger.yaml` - OpenAPI 2.0 (Swagger) specification (if `--swagger` flag is used)
157
201
158
202
**Extending to new providers**: Simply create `aliases-{provider}.tsp` and the script will automatically detect and support it.
159
203
@@ -174,6 +218,12 @@ If you prefer to build manually:
**Note**: The `aliases.tsp` file controls which provider-specific `ClusterSpec` definition is used throughout the service definitions. By re-linking it to either `aliases-core.tsp` or `aliases-gcp.tsp`, you switch between the generic `Record<unknown>` spec and the GCP-specific `GCPClusterSpec`.
191
247
192
248
## Architecture
@@ -249,6 +305,7 @@ To add a new service (e.g., with additional endpoints):
249
305
-`@typespec/http` - HTTP protocol support
250
306
-`@typespec/openapi` - OpenAPI decorators
251
307
-`@typespec/openapi3` - OpenAPI 3.0 emitter
308
+
-`api-spec-converter` - Converts OpenAPI 3.0 to OpenAPI 2.0 (Swagger)
252
309
253
310
254
311
## Developing with the Visual Studio Typespec extension
0 commit comments