-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const { openapiToTsJsonSchema, fastifyIntegrationPlugin } = require('openapi-ts-json-schema'); | ||
|
||
const FILENAME = 'component-separator-error.yaml'; | ||
const OUTPUT_PATH = path.resolve(__dirname, `generated-${path.basename(FILENAME, path.extname(FILENAME))}`); | ||
|
||
async function processSpec(filename) { | ||
return openapiToTsJsonSchema({ | ||
openApiSchema: path.resolve(__dirname, FILENAME), | ||
definitionPathsToGenerateFrom: ['paths', 'components.schemas'], | ||
refHandling: 'keep', | ||
outputPath: OUTPUT_PATH, | ||
plugins: [ | ||
fastifyIntegrationPlugin({ | ||
sharedSchemasFilter: ({ schemaId }) => schemaId.startsWith('/components/schemas'), | ||
}), | ||
], | ||
}); | ||
} | ||
|
||
async function generate() { | ||
// does not throw | ||
await assert.doesNotReject(processSpec(FILENAME)); | ||
|
||
// contains the expected import | ||
const fastifyIntegrationContens = fs.readFileSync(path.resolve(OUTPUT_PATH, 'fastify-integration.ts'), 'utf8'); | ||
assert.ok(fastifyIntegrationContens.includes('import componentsSchemasHelloWorld from "./components/schemas/HelloWorld";')); | ||
} | ||
|
||
generate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters