Skip to content

Commit a31103f

Browse files
Warn on schema fallback (#25)
* Added warning when falling back to unknown type * Bumped version * Moved warning to schemaTypes to ensure that warnings are not duplicated * Added falling back message
1 parent 12ea8d3 commit a31103f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyapi",
3-
"version": "0.24.8",
3+
"version": "0.24.9",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

src/commands/generate/schemaTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { EOL } from 'node:os';
55
import { SchemaRef, SchemaSpecification } from '../../types';
66
import { echoGenerationError } from '../../utils';
77
import { setGenerationErrors } from './types';
8+
import shell from 'shelljs'
9+
import chalk from 'chalk';
810

911
const unsafeCharacters = /(?:^\d)|[^0-9a-zA-Z_]/gi;
1012
const unescapedSingleQuote = /\b'\b/gi;
@@ -678,6 +680,9 @@ const fillInUnresolvedSchemas = (specs: SchemaSpec[]): SchemaSpec[] => {
678680
visibility: 'ENVIRONMENT',
679681
},
680682
};
683+
shell.echo(
684+
chalk.yellow(`WARNING: Referenced Schema '${unresolved.path}' is unresolved. Falling back to 'unknown' type.`)
685+
);
681686
schemas.set(unresolved.path, fillerSpec);
682687
}
683688
}
@@ -704,6 +709,9 @@ const fillInUnresolvedSchemas = (specs: SchemaSpec[]): SchemaSpec[] => {
704709
visibility: 'ENVIRONMENT',
705710
},
706711
};
712+
shell.echo(
713+
chalk.yellow(`WARNING: Referenced Schema '${contextName}' is unresolved, as context \`${context}\` was not generated. Falling back to 'unknown' type.`)
714+
);
707715
schemas.set(contextName, fillerSpec);
708716
}
709717
}

0 commit comments

Comments
 (0)