Skip to content

Commit 64697eb

Browse files
committed
refactor: change output schema name
1 parent 9f8907d commit 64697eb

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

types/codegen/openapitools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"generatorName": "typescript-fetch",
99
"disabled": false,
1010
"output": "#{cwd}/generated/typescript",
11-
"inputSpec": "#{cwd}/schema/final-output.json",
11+
"inputSpec": "#{cwd}/schema/complete-schema.json",
1212
"templateDir": "#{cwd}/custom-templates/typescript",
1313
"additionalProperties": {
1414
"supportsES6": true,
@@ -41,7 +41,7 @@
4141
"generatorName": "java",
4242
"disabled": false,
4343
"output": "#{cwd}/generated/java",
44-
"inputSpec": "#{cwd}/schema/final-output.json",
44+
"inputSpec": "#{cwd}/schema/complete-schema.json",
4545
"templateDir": "#{cwd}/custom-templates/java",
4646
"additionalProperties": {
4747
"useOneOfInterfaces": true,

types/codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Generate TypeScript defintiinons from JSON Schema using OpenAPI Generator",
55
"main": "generated/typescript/src/index.ts",
66
"scripts": {
7-
"generate-schema": "node scripts/pre-all.js",
7+
"generate-schema": "node scripts/generate-complete-schema.js",
88
"generate": "npm run generate-schema && openapi-generator-cli generate && node scripts/post-typescript.js && npm run test",
99
"generate:no-post": "npm run generate-schema && openapi-generator-cli generate",
1010
"test": "node scripts/post-test.js",

types/codegen/scripts/pre-all.js renamed to types/codegen/scripts/generate-complete-schema.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const fs = require('fs')
44
const path = require('path')
55

66
// Pre-generation script for all generators
7-
// Combines all schema files in the schema directory and creates final-output.json with OpenAPI wrapper
7+
// Combines all schema files in the schema directory and creates complete-schema.json with OpenAPI wrapper
88

99
const schemaDir = path.join(__dirname, '../schema')
10-
const finalOutputPath = path.join(__dirname, '../schema/final-output.json')
10+
const completeSchemaPath = path.join(__dirname, '../schema/complete-schema.json')
1111
const openapiConfigPath = path.join(__dirname, '../openapitools.json')
1212

1313
// Validate required directories and files exist
@@ -72,8 +72,8 @@ function processSchemaFiles() {
7272
try {
7373
const files = fs.readdirSync(schemaDir)
7474

75-
// Filter for JSON files, excluding final-output.json
76-
const jsonFiles = files.filter(file => file.endsWith('.json') && file !== 'final-output.json')
75+
// Filter for JSON files, excluding complete-schema.json
76+
const jsonFiles = files.filter(file => file.endsWith('.json') && file !== 'complete-schema.json')
7777

7878
if (jsonFiles.length === 0) {
7979
console.error('Error: No JSON schema files found in schema directory')
@@ -185,25 +185,25 @@ if (!schemas || Object.keys(schemas).length === 0) {
185185
process.exit(1)
186186
}
187187

188-
// create the final output with header + schemas + footer
189-
const finalOutput = {
188+
// create the complete schema with header + schemas + footer
189+
const completeSchema = {
190190
...openApiHeader,
191191
components: {
192192
schemas: schemas,
193193
},
194194
}
195195

196-
// write full OpenAPI spec to final-output.json
196+
// write full OpenAPI spec to complete-schema.json
197197
try {
198-
fs.writeFileSync(finalOutputPath, JSON.stringify(finalOutput, null, 4))
198+
fs.writeFileSync(completeSchemaPath, JSON.stringify(completeSchema, null, 4))
199199

200-
console.log(`\nComplete OpenAPI structure created in final-output.json (version: ${version})`)
200+
console.log(`\nComplete OpenAPI structure created in complete-schema.json (version: ${version})`)
201201
console.log(`Combined ${Object.keys(schemas).length} total schemas from ${files.length} files: ${files.join(', ')}`)
202202

203203
if (skipped > 0 || errors > 0) {
204204
console.log(`Processing summary: ${files.length} successful, ${skipped} skipped, ${errors} errors`)
205205
}
206206
} catch (error) {
207-
console.error('Error writing final-output.json:', error.message)
207+
console.error('Error writing complete-schema.json:', error.message)
208208
process.exit(1)
209209
}

types/codegen/scripts/post-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ const fs = require('fs')
44
const path = require('path')
55

66
// Post-test script to validate generated models against schema definitions
7-
// Compares models in final-output.json with generated TypeScript and Java models
7+
// Compares models in complete-schema.json with generated TypeScript and Java models
88
// Usage: node post-test.js [--verbose]
99

1010
// Parse command line arguments
1111
const args = process.argv.slice(2)
1212
const verbose = args.includes('--verbose') || args.includes('-v')
1313

1414
// File paths
15-
const finalOutputPath = path.join(__dirname, '../schema/final-output.json')
15+
const completeSchemaPath = path.join(__dirname, '../schema/complete-schema.json')
1616
const typescriptModelsPath = path.join(__dirname, '../generated/typescript/src/models/index.ts')
1717
const javaModelsDir = path.join(__dirname, '../generated/java/src/main/java/org/openapitools/client/model')
1818
const openapiConfigPath = path.join(__dirname, '../openapitools.json')
1919

2020
console.log('Starting model validation...\n')
2121

22-
// Check if final-output.json exists
23-
if (!fs.existsSync(finalOutputPath)) {
24-
console.error('Error: final-output.json not found in schema directory')
22+
// Check if complete-schema.json exists
23+
if (!fs.existsSync(completeSchemaPath)) {
24+
console.error('Error: complete-schema.json not found in schema directory')
2525
console.error(' Run "npm run generate-schema" first to create the schema file')
2626
process.exit(1)
2727
}
@@ -49,21 +49,21 @@ try {
4949
console.warn('Warning: Could not read OpenAPI configuration:', error.message)
5050
}
5151

52-
// Load and parse final-output.json
52+
// Load and parse complete-schema.json
5353
let schemaModels = new Set()
5454
try {
55-
const finalOutput = JSON.parse(fs.readFileSync(finalOutputPath, 'utf8'))
55+
const completeSchema = JSON.parse(fs.readFileSync(completeSchemaPath, 'utf8'))
5656

57-
if (!finalOutput.components || !finalOutput.components.schemas) {
58-
console.error('Error: Invalid OpenAPI structure in final-output.json')
57+
if (!completeSchema.components || !completeSchema.components.schemas) {
58+
console.error('Error: Invalid OpenAPI structure in complete-schema.json')
5959
console.error(' Missing components.schemas section')
6060
process.exit(1)
6161
}
6262

63-
schemaModels = new Set(Object.keys(finalOutput.components.schemas))
63+
schemaModels = new Set(Object.keys(completeSchema.components.schemas))
6464
console.log(`Found ${schemaModels.size} models in schema\n`)
6565
} catch (error) {
66-
console.error('Error parsing final-output.json:', error.message)
66+
console.error('Error parsing complete-schema.json:', error.message)
6767
process.exit(1)
6868
}
6969

0 commit comments

Comments
 (0)