@contractspec/lib.contracts-transformers 3.7.10 → 3.7.12
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/dist/browser/index.js +57 -0
- package/dist/browser/openapi/index.js +57 -0
- package/dist/index.js +57 -0
- package/dist/node/index.js +57 -0
- package/dist/node/openapi/index.js +57 -0
- package/dist/openapi/index.d.ts +2 -0
- package/dist/openapi/index.js +57 -0
- package/package.json +5 -5
package/dist/browser/index.js
CHANGED
|
@@ -2358,6 +2358,62 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2358
2358
|
const doc = parseOpenApiString(content, format);
|
|
2359
2359
|
return parseOpenApiDocument(doc, options);
|
|
2360
2360
|
}
|
|
2361
|
+
// src/openapi/index.ts
|
|
2362
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2363
|
+
{
|
|
2364
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2365
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2366
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2367
|
+
kind: "reference",
|
|
2368
|
+
visibility: "public",
|
|
2369
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2370
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2371
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2372
|
+
|
|
2373
|
+
### Purpose
|
|
2374
|
+
|
|
2375
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2376
|
+
|
|
2377
|
+
### Modes
|
|
2378
|
+
|
|
2379
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2380
|
+
|
|
2381
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2382
|
+
|
|
2383
|
+
\`\`\`bash
|
|
2384
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2385
|
+
\`\`\`
|
|
2386
|
+
|
|
2387
|
+
#### 2. Multi-Format Generation
|
|
2388
|
+
|
|
2389
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2390
|
+
|
|
2391
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2392
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2393
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2394
|
+
|
|
2395
|
+
\`\`\`bash
|
|
2396
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2397
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2398
|
+
\`\`\`
|
|
2399
|
+
|
|
2400
|
+
### Library API
|
|
2401
|
+
|
|
2402
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2403
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2404
|
+
- Options:
|
|
2405
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2406
|
+
- \`prefix\`: Prefix for model names
|
|
2407
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2408
|
+
|
|
2409
|
+
### CLI
|
|
2410
|
+
|
|
2411
|
+
\`\`\`bash
|
|
2412
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2413
|
+
\`\`\`
|
|
2414
|
+
`
|
|
2415
|
+
}
|
|
2416
|
+
];
|
|
2361
2417
|
export {
|
|
2362
2418
|
toValidIdentifier,
|
|
2363
2419
|
toSpecKey,
|
|
@@ -2370,6 +2426,7 @@ export {
|
|
|
2370
2426
|
toHttpMethod,
|
|
2371
2427
|
toFileName,
|
|
2372
2428
|
toCamelCase,
|
|
2429
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2373
2430
|
schemaModelToJsonSchema,
|
|
2374
2431
|
parseOpenApiString,
|
|
2375
2432
|
parseOpenApiDocument,
|
|
@@ -2359,11 +2359,68 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2359
2359
|
const doc = parseOpenApiString(content, format);
|
|
2360
2360
|
return parseOpenApiDocument(doc, options);
|
|
2361
2361
|
}
|
|
2362
|
+
// src/openapi/index.ts
|
|
2363
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2364
|
+
{
|
|
2365
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2366
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2367
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2368
|
+
kind: "reference",
|
|
2369
|
+
visibility: "public",
|
|
2370
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2371
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2372
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2373
|
+
|
|
2374
|
+
### Purpose
|
|
2375
|
+
|
|
2376
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2377
|
+
|
|
2378
|
+
### Modes
|
|
2379
|
+
|
|
2380
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2381
|
+
|
|
2382
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2383
|
+
|
|
2384
|
+
\`\`\`bash
|
|
2385
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2386
|
+
\`\`\`
|
|
2387
|
+
|
|
2388
|
+
#### 2. Multi-Format Generation
|
|
2389
|
+
|
|
2390
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2391
|
+
|
|
2392
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2393
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2394
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2395
|
+
|
|
2396
|
+
\`\`\`bash
|
|
2397
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2398
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2399
|
+
\`\`\`
|
|
2400
|
+
|
|
2401
|
+
### Library API
|
|
2402
|
+
|
|
2403
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2404
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2405
|
+
- Options:
|
|
2406
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2407
|
+
- \`prefix\`: Prefix for model names
|
|
2408
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2409
|
+
|
|
2410
|
+
### CLI
|
|
2411
|
+
|
|
2412
|
+
\`\`\`bash
|
|
2413
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2414
|
+
\`\`\`
|
|
2415
|
+
`
|
|
2416
|
+
}
|
|
2417
|
+
];
|
|
2362
2418
|
export {
|
|
2363
2419
|
toSchemaName,
|
|
2364
2420
|
toRestPath,
|
|
2365
2421
|
toOperationId,
|
|
2366
2422
|
toHttpMethod,
|
|
2423
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2367
2424
|
schemaModelToJsonSchema,
|
|
2368
2425
|
parseOpenApiString,
|
|
2369
2426
|
parseOpenApiDocument,
|
package/dist/index.js
CHANGED
|
@@ -2359,6 +2359,62 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2359
2359
|
const doc = parseOpenApiString(content, format);
|
|
2360
2360
|
return parseOpenApiDocument(doc, options);
|
|
2361
2361
|
}
|
|
2362
|
+
// src/openapi/index.ts
|
|
2363
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2364
|
+
{
|
|
2365
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2366
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2367
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2368
|
+
kind: "reference",
|
|
2369
|
+
visibility: "public",
|
|
2370
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2371
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2372
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2373
|
+
|
|
2374
|
+
### Purpose
|
|
2375
|
+
|
|
2376
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2377
|
+
|
|
2378
|
+
### Modes
|
|
2379
|
+
|
|
2380
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2381
|
+
|
|
2382
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2383
|
+
|
|
2384
|
+
\`\`\`bash
|
|
2385
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2386
|
+
\`\`\`
|
|
2387
|
+
|
|
2388
|
+
#### 2. Multi-Format Generation
|
|
2389
|
+
|
|
2390
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2391
|
+
|
|
2392
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2393
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2394
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2395
|
+
|
|
2396
|
+
\`\`\`bash
|
|
2397
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2398
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2399
|
+
\`\`\`
|
|
2400
|
+
|
|
2401
|
+
### Library API
|
|
2402
|
+
|
|
2403
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2404
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2405
|
+
- Options:
|
|
2406
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2407
|
+
- \`prefix\`: Prefix for model names
|
|
2408
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2409
|
+
|
|
2410
|
+
### CLI
|
|
2411
|
+
|
|
2412
|
+
\`\`\`bash
|
|
2413
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2414
|
+
\`\`\`
|
|
2415
|
+
`
|
|
2416
|
+
}
|
|
2417
|
+
];
|
|
2362
2418
|
export {
|
|
2363
2419
|
toValidIdentifier,
|
|
2364
2420
|
toSpecKey,
|
|
@@ -2371,6 +2427,7 @@ export {
|
|
|
2371
2427
|
toHttpMethod,
|
|
2372
2428
|
toFileName,
|
|
2373
2429
|
toCamelCase,
|
|
2430
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2374
2431
|
schemaModelToJsonSchema,
|
|
2375
2432
|
parseOpenApiString,
|
|
2376
2433
|
parseOpenApiDocument,
|
package/dist/node/index.js
CHANGED
|
@@ -2358,6 +2358,62 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2358
2358
|
const doc = parseOpenApiString(content, format);
|
|
2359
2359
|
return parseOpenApiDocument(doc, options);
|
|
2360
2360
|
}
|
|
2361
|
+
// src/openapi/index.ts
|
|
2362
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2363
|
+
{
|
|
2364
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2365
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2366
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2367
|
+
kind: "reference",
|
|
2368
|
+
visibility: "public",
|
|
2369
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2370
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2371
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2372
|
+
|
|
2373
|
+
### Purpose
|
|
2374
|
+
|
|
2375
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2376
|
+
|
|
2377
|
+
### Modes
|
|
2378
|
+
|
|
2379
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2380
|
+
|
|
2381
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2382
|
+
|
|
2383
|
+
\`\`\`bash
|
|
2384
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2385
|
+
\`\`\`
|
|
2386
|
+
|
|
2387
|
+
#### 2. Multi-Format Generation
|
|
2388
|
+
|
|
2389
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2390
|
+
|
|
2391
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2392
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2393
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2394
|
+
|
|
2395
|
+
\`\`\`bash
|
|
2396
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2397
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2398
|
+
\`\`\`
|
|
2399
|
+
|
|
2400
|
+
### Library API
|
|
2401
|
+
|
|
2402
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2403
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2404
|
+
- Options:
|
|
2405
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2406
|
+
- \`prefix\`: Prefix for model names
|
|
2407
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2408
|
+
|
|
2409
|
+
### CLI
|
|
2410
|
+
|
|
2411
|
+
\`\`\`bash
|
|
2412
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2413
|
+
\`\`\`
|
|
2414
|
+
`
|
|
2415
|
+
}
|
|
2416
|
+
];
|
|
2361
2417
|
export {
|
|
2362
2418
|
toValidIdentifier,
|
|
2363
2419
|
toSpecKey,
|
|
@@ -2370,6 +2426,7 @@ export {
|
|
|
2370
2426
|
toHttpMethod,
|
|
2371
2427
|
toFileName,
|
|
2372
2428
|
toCamelCase,
|
|
2429
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2373
2430
|
schemaModelToJsonSchema,
|
|
2374
2431
|
parseOpenApiString,
|
|
2375
2432
|
parseOpenApiDocument,
|
|
@@ -2359,11 +2359,68 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2359
2359
|
const doc = parseOpenApiString(content, format);
|
|
2360
2360
|
return parseOpenApiDocument(doc, options);
|
|
2361
2361
|
}
|
|
2362
|
+
// src/openapi/index.ts
|
|
2363
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2364
|
+
{
|
|
2365
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2366
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2367
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2368
|
+
kind: "reference",
|
|
2369
|
+
visibility: "public",
|
|
2370
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2371
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2372
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2373
|
+
|
|
2374
|
+
### Purpose
|
|
2375
|
+
|
|
2376
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2377
|
+
|
|
2378
|
+
### Modes
|
|
2379
|
+
|
|
2380
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2381
|
+
|
|
2382
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2383
|
+
|
|
2384
|
+
\`\`\`bash
|
|
2385
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2386
|
+
\`\`\`
|
|
2387
|
+
|
|
2388
|
+
#### 2. Multi-Format Generation
|
|
2389
|
+
|
|
2390
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2391
|
+
|
|
2392
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2393
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2394
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2395
|
+
|
|
2396
|
+
\`\`\`bash
|
|
2397
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2398
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2399
|
+
\`\`\`
|
|
2400
|
+
|
|
2401
|
+
### Library API
|
|
2402
|
+
|
|
2403
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2404
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2405
|
+
- Options:
|
|
2406
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2407
|
+
- \`prefix\`: Prefix for model names
|
|
2408
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2409
|
+
|
|
2410
|
+
### CLI
|
|
2411
|
+
|
|
2412
|
+
\`\`\`bash
|
|
2413
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2414
|
+
\`\`\`
|
|
2415
|
+
`
|
|
2416
|
+
}
|
|
2417
|
+
];
|
|
2362
2418
|
export {
|
|
2363
2419
|
toSchemaName,
|
|
2364
2420
|
toRestPath,
|
|
2365
2421
|
toOperationId,
|
|
2366
2422
|
toHttpMethod,
|
|
2423
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2367
2424
|
schemaModelToJsonSchema,
|
|
2368
2425
|
parseOpenApiString,
|
|
2369
2426
|
parseOpenApiDocument,
|
package/dist/openapi/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* OpenAPI transformation module.
|
|
3
3
|
* Import/export between ContractSpec and OpenAPI 3.x.
|
|
4
4
|
*/
|
|
5
|
+
import type { DocBlock } from '@contractspec/lib.contracts-spec/docs';
|
|
5
6
|
export { createSpecDiff, type DiffOptions, diffAll, diffSpecs, diffSpecVsOperation, formatDiffChanges, } from './differ';
|
|
6
7
|
export { type ContractSpecRegistries, contractSpecToJson, contractSpecToYaml, defaultRestPath, exportContractSpec, openApiForRegistry, openApiToJson, openApiToYaml, } from './exporter';
|
|
7
8
|
export * from './exporter/index';
|
|
@@ -9,3 +10,4 @@ export { importFromOpenApi, importOperation } from './importer';
|
|
|
9
10
|
export { detectFormat, detectVersion, parseOpenApi, parseOpenApiDocument, parseOpenApiString, } from './parser';
|
|
10
11
|
export { type GeneratedModel, generateImports, generateSchemaModelCode, getScalarType, jsonSchemaToType, type SchemaField, type TypescriptType, } from './schema-converter';
|
|
11
12
|
export type { ContractSpecOpenApiDocument, HttpMethod, OpenApiDocument, OpenApiExportOptions, OpenApiOperation, OpenApiParameter, OpenApiParseOptions, OpenApiSchema, OpenApiServer, OpenApiSource, OpenApiTransportHints, OpenApiVersion, ParameterLocation, ParsedOperation, ParsedParameter, ParseResult, } from './types';
|
|
13
|
+
export declare const tech_contracts_openapi_import_DocBlocks: DocBlock[];
|
package/dist/openapi/index.js
CHANGED
|
@@ -2360,11 +2360,68 @@ async function parseOpenApi(source, options = {}) {
|
|
|
2360
2360
|
const doc = parseOpenApiString(content, format);
|
|
2361
2361
|
return parseOpenApiDocument(doc, options);
|
|
2362
2362
|
}
|
|
2363
|
+
// src/openapi/index.ts
|
|
2364
|
+
var tech_contracts_openapi_import_DocBlocks = [
|
|
2365
|
+
{
|
|
2366
|
+
id: "docs.tech.contracts.openapi-import",
|
|
2367
|
+
title: "OpenAPI Import (OpenAPI 3.1) to ContractSpec",
|
|
2368
|
+
summary: "Import OpenAPI specifications into ContractSpec models, or generate pure Zod/JSON-Schema/GraphQL representations.",
|
|
2369
|
+
kind: "reference",
|
|
2370
|
+
visibility: "public",
|
|
2371
|
+
route: "/docs/tech/contracts/openapi-import",
|
|
2372
|
+
tags: ["contracts", "openapi", "import", "codegen"],
|
|
2373
|
+
body: `## OpenAPI Import (OpenAPI 3.1)
|
|
2374
|
+
|
|
2375
|
+
### Purpose
|
|
2376
|
+
|
|
2377
|
+
Import external API definitions into your codebase. Supports both one-time scaffolding and multi-format generation for integration.
|
|
2378
|
+
|
|
2379
|
+
### Modes
|
|
2380
|
+
|
|
2381
|
+
#### 1. ContractSpec Scaffolding (Default)
|
|
2382
|
+
|
|
2383
|
+
Generates standard \`defineSchemaModel\` definitions for full ContractSpec integration.
|
|
2384
|
+
|
|
2385
|
+
\`\`\`bash
|
|
2386
|
+
contractspec openapi import --file api.json --output ./src/contracts
|
|
2387
|
+
\`\`\`
|
|
2388
|
+
|
|
2389
|
+
#### 2. Multi-Format Generation
|
|
2390
|
+
|
|
2391
|
+
Generate schemas in specific formats for direct use in other parts of your stack (adapters, UI, etc.).
|
|
2392
|
+
|
|
2393
|
+
- **Zod**: Pure Zod schemas (\`z.object(...)\`).
|
|
2394
|
+
- **GraphQL**: GraphQL SDL type definitions.
|
|
2395
|
+
- **JSON Schema**: Standard JSON Schema objects.
|
|
2396
|
+
|
|
2397
|
+
\`\`\`bash
|
|
2398
|
+
# Generate Zod schemas suitable for runtime validation
|
|
2399
|
+
contractspec openapi import --file api.json --output ./src/zod --schema-format zod
|
|
2400
|
+
\`\`\`
|
|
2401
|
+
|
|
2402
|
+
### Library API
|
|
2403
|
+
|
|
2404
|
+
- Function: \`importFromOpenApi(doc, options)\`
|
|
2405
|
+
- Location: \`@contractspec/lib.contracts-transformers/openapi\`
|
|
2406
|
+
- Options:
|
|
2407
|
+
- \`schemaFormat\`: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
2408
|
+
- \`prefix\`: Prefix for model names
|
|
2409
|
+
- \`tags\`: Filter by OpenAPI tags
|
|
2410
|
+
|
|
2411
|
+
### CLI
|
|
2412
|
+
|
|
2413
|
+
\`\`\`bash
|
|
2414
|
+
contractspec openapi import --file <path-or-url> --output <dir> [--schema-format <format>]
|
|
2415
|
+
\`\`\`
|
|
2416
|
+
`
|
|
2417
|
+
}
|
|
2418
|
+
];
|
|
2363
2419
|
export {
|
|
2364
2420
|
toSchemaName,
|
|
2365
2421
|
toRestPath,
|
|
2366
2422
|
toOperationId,
|
|
2367
2423
|
toHttpMethod,
|
|
2424
|
+
tech_contracts_openapi_import_DocBlocks,
|
|
2368
2425
|
schemaModelToJsonSchema,
|
|
2369
2426
|
parseOpenApiString,
|
|
2370
2427
|
parseOpenApiDocument,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.contracts-transformers",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.12",
|
|
4
4
|
"description": "Contract format transformations: import/export between ContractSpec and external formats (OpenAPI, AsyncAPI, etc.)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"typecheck": "tsc --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@contractspec/lib.contracts-spec": "
|
|
31
|
-
"@contractspec/lib.schema": "3.7.
|
|
30
|
+
"@contractspec/lib.contracts-spec": "5.0.0",
|
|
31
|
+
"@contractspec/lib.schema": "3.7.10",
|
|
32
32
|
"compare-versions": "^6.1.1",
|
|
33
33
|
"openapi-types": "^12.1.3",
|
|
34
34
|
"yaml": "^2.7.1",
|
|
35
35
|
"zod": "^4.3.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@contractspec/tool.typescript": "3.7.
|
|
38
|
+
"@contractspec/tool.typescript": "3.7.9",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
|
-
"@contractspec/tool.bun": "3.7.
|
|
40
|
+
"@contractspec/tool.bun": "3.7.9"
|
|
41
41
|
},
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
43
|
"files": [
|