Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solving blackbox tests problems #905

Merged
merged 59 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d13c267
Fixing dependencies
jonaslagoni Sep 27, 2022
c46e70f
fixed renderer
jonaslagoni Sep 27, 2022
8e6150b
fixed blackbox
jonaslagoni Sep 27, 2022
f103f82
add test
jonaslagoni Sep 27, 2022
dd4ddab
Fixed linter
jonaslagoni Sep 27, 2022
cdaf662
fixed dependencies
jonaslagoni Sep 27, 2022
9bf54a7
Fixed unique implementation
jonaslagoni Sep 27, 2022
6f1d6c6
fixed linter
jonaslagoni Sep 27, 2022
bb673d7
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Sep 27, 2022
c7e8c1d
Merge remote-tracking branch 'origin/feature/fix_python_generator_wit…
jonaslagoni Sep 27, 2022
80af36d
Merge remote-tracking branch 'origin/feature/fix_self_dependencies' i…
jonaslagoni Sep 27, 2022
c475eee
WIP
jonaslagoni Sep 28, 2022
fff0d08
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Oct 3, 2022
e57f7c5
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Oct 4, 2022
e31e2bc
Fixed implementation and test
jonaslagoni Oct 5, 2022
c1ccf69
add fix and implementation
jonaslagoni Oct 5, 2022
a7d7649
update snapshot
jonaslagoni Oct 5, 2022
061a31b
wip
jonaslagoni Oct 4, 2022
cca613a
Merge remote-tracking branch 'origin/feature/fix_typescript_array_typ…
jonaslagoni Oct 5, 2022
a9dce75
Merge remote-tracking branch 'origin/feature/fix_javascript_splits_ou…
jonaslagoni Oct 5, 2022
4c7e6c3
add implementation and test
jonaslagoni Oct 5, 2022
aed9512
fixed linter
jonaslagoni Oct 6, 2022
921da11
Merge remote-tracking branch 'origin/feature/fix_java_maps_cannot_hav…
jonaslagoni Oct 6, 2022
89a94e0
wip
jonaslagoni Oct 17, 2022
35239a2
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Nov 9, 2022
61aec5f
fixed rest of the problems
jonaslagoni Nov 10, 2022
a3ba013
removed unused test file
jonaslagoni Nov 10, 2022
7c2501f
fixed lint
jonaslagoni Nov 10, 2022
5395956
separated blackbox tests and scripts
jonaslagoni Nov 10, 2022
cf0d339
re-added files
jonaslagoni Nov 10, 2022
40e965c
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Nov 10, 2022
2c4de23
updated packagelock
jonaslagoni Nov 10, 2022
7911d28
rename
jonaslagoni Nov 10, 2022
71001e6
fixed linter
jonaslagoni Nov 10, 2022
92bac61
fixed more problems
jonaslagoni Nov 15, 2022
3fe7b78
wip
jonaslagoni Nov 17, 2022
74e7b87
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Nov 17, 2022
1fb9f15
update
jonaslagoni Nov 17, 2022
19fa426
renamed parameter
jonaslagoni Nov 17, 2022
8ff1ade
fixed incorrect test scripts was run
jonaslagoni Nov 17, 2022
2114dd2
removed unused file
jonaslagoni Nov 18, 2022
1792c05
added comments
jonaslagoni Nov 23, 2022
24e2651
fixed tests and implementation
jonaslagoni Nov 23, 2022
c6abd12
Merge branch 'next' into feature/fix_pattern_properties_problem
jonaslagoni Nov 23, 2022
af13a3c
removed unneccessary newline
jonaslagoni Nov 23, 2022
30da8fd
Merge branch 'feature/fix_pattern_properties_problem' into feature/fi…
jonaslagoni Nov 23, 2022
c7efd32
Revert "Merge branch 'feature/fix_pattern_properties_problem' into fe…
jonaslagoni Nov 23, 2022
18e6b04
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Nov 23, 2022
3fb1864
Merge branch 'next' into feature/fix_all_blackbox_tests
jonaslagoni Nov 23, 2022
69990b3
update packagelock
jonaslagoni Nov 23, 2022
c001815
readded overwritten changes
jonaslagoni Nov 23, 2022
39e536c
fixed remaining errors
jonaslagoni Nov 23, 2022
b33735a
fixed docs and test
jonaslagoni Nov 23, 2022
e7bdc25
update snapshots
jonaslagoni Nov 23, 2022
f34b318
streamlined the file generator options across all generators
jonaslagoni Nov 23, 2022
bd04d79
Revert "streamlined the file generator options across all generators"
jonaslagoni Nov 28, 2022
64981f9
Simplify tests
jonaslagoni Nov 28, 2022
9d99881
fixed lint
jonaslagoni Nov 28, 2022
96dbd09
fixed test and lint
jonaslagoni Nov 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('LANGUAGE_MY_PRESET', () => {
beforeEach(() => {
generator = new LanguageGenerator({ presets: [LANGUAGE_MY_PRESET] });
});

test('should render xxx', async () => {
const input = {
$id: 'Clazz',
Expand Down
2 changes: 1 addition & 1 deletion docs/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Root {
}
```

The preset renderes the TypeScript class by calling **preset hooks**, which is callbacks that is called for rendering parts of the class.
The generator renderes the TypeScript class by calling **preset hooks**, which is callbacks that is called for rendering parts of the class.
```html
<self>
<properties />
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/generators/csharp/CSharpFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class CSharpFileGenerator extends CSharpGenerator implements AbstractFile
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: CSharpRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: CSharpRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.cs`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
5 changes: 3 additions & 2 deletions src/generators/dart/DartFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class DartFileGenerator extends DartGenerator implements AbstractFileGene
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: DartRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: DartRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
jonaslagoni marked this conversation as resolved.
Show resolved Hide resolved
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.dart`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
5 changes: 3 additions & 2 deletions src/generators/go/GoFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class GoFileGenerator extends GoGenerator implements AbstractFileGenerato
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: GoRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: GoRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.go`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
2 changes: 1 addition & 1 deletion src/generators/java/JavaConstrainer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConstrainedEnumValueModel } from 'models';
import { ConstrainedEnumValueModel } from '../../models';
import { TypeMapping } from '../../helpers';
import { defaultEnumKeyConstraints, defaultEnumValueConstraints } from './constrainer/EnumConstrainer';
import { defaultModelNameConstraints } from './constrainer/ModelNameConstrainer';
Expand Down
5 changes: 3 additions & 2 deletions src/generators/java/JavaFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class JavaFileGenerator extends JavaGenerator implements AbstractFileGene
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: JavaRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: JavaRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.java`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
3 changes: 1 addition & 2 deletions src/generators/java/JavaPreset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ConstrainedEnumModel } from 'models/ConstrainedMetaModel';
import { Preset, ClassPreset, EnumPreset, PresetArgs, EnumArgs } from '../../models';
import { Preset, ClassPreset, EnumPreset, PresetArgs, EnumArgs, ConstrainedEnumModel } from '../../models';
import { JavaOptions } from './JavaGenerator';
import { ClassRenderer, JAVA_DEFAULT_CLASS_PRESET } from './renderers/ClassRenderer';
import { EnumRenderer, JAVA_DEFAULT_ENUM_PRESET } from './renderers/EnumRenderer';
Expand Down
5 changes: 3 additions & 2 deletions src/generators/javascript/JavaScriptFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class JavaScriptFileGenerator extends JavaScriptGenerator implements Abst
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options?: JavaScriptRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options?: JavaScriptRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options || {});
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.js`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
5 changes: 3 additions & 2 deletions src/generators/python/PythonFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class PythonFileGenerator extends PythonGenerator implements AbstractFile
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: PythonRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: PythonRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.py`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
12 changes: 7 additions & 5 deletions src/generators/rust/RustFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ export class RustFileGenerator extends RustGenerator implements AbstractFileGene
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: RustRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: RustRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options);
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== '' && outputModel.modelName !== undefined; });
for (const outputModel of generatedModels) {
const fileName = FormatHelpers.snakeCase(outputModel.modelName);
const filePath = path.resolve(outputDirectory, `${fileName}.rs`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand All @@ -30,18 +31,19 @@ export class RustFileGenerator extends RustGenerator implements AbstractFileGene
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToPackage(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: RustRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToPackage(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options: RustRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
// Crate package expects source code to be written to src/<filename>.rs
const sourceOutputDirectory = `${outputDirectory}/src`;
let generatedModels = await this.generateToFiles(input, sourceOutputDirectory, options);
let generatedModels = await this.generateToFiles(input, sourceOutputDirectory, options, ensureFilesWritten);
// render lib.rs and Cargo.toml
if (options.supportFiles) {
const supportOutput = await this.generateCompleteSupport(input, options);
generatedModels = generatedModels.concat(supportOutput);
for (const outputModel of supportOutput) {
const filePath = path.resolve(outputDirectory, outputModel.model.name);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
}
return generatedModels;
Expand Down
2 changes: 1 addition & 1 deletion src/generators/rust/constrainer/EnumConstrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function defaultEnumKeyConstraints(customConstraints?: Partial<ModelEnumK
}

export function defaultEnumValueConstraints(): EnumValueConstraint {
return ({enumValue}) => {
return ({ enumValue }) => {
return enumValue;
};
}
5 changes: 3 additions & 2 deletions src/generators/typescript/TypeScriptFileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export class TypeScriptFileGenerator extends TypeScriptGenerator implements Abst
* @param input
* @param outputDirectory where you want the models generated to
* @param options
* @param ensureFilesWritten verify that the files is completely written before returning, this can happen if the file system is swamped with write requests.
*/
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options?: TypeScriptRenderCompleteModelOptions): Promise<OutputModel[]> {
public async generateToFiles(input: Record<string, unknown> | InputMetaModel, outputDirectory: string, options?: TypeScriptRenderCompleteModelOptions, ensureFilesWritten = false): Promise<OutputModel[]> {
let generatedModels = await this.generateCompleteModels(input, options || {});
//Filter anything out that have not been successfully generated
generatedModels = generatedModels.filter((outputModel) => { return outputModel.modelName !== ''; });
for (const outputModel of generatedModels) {
const filePath = path.resolve(outputDirectory, `${outputModel.modelName}.ts`);
await FileHelpers.writerToFileSystem(outputModel.result, filePath);
await FileHelpers.writerToFileSystem(outputModel.result, filePath, ensureFilesWritten);
}
return generatedModels;
}
Expand Down
6 changes: 3 additions & 3 deletions src/generators/typescript/TypeScriptGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
defaultGeneratorOptions
} from '../AbstractGenerator';
import { ConstrainedEnumModel, ConstrainedMetaModel, ConstrainedObjectModel, InputMetaModel, MetaModel, RenderOutput } from '../../models';
import { constrainMetaModel, Constraints, split, TypeMapping, hasPreset, renderJavaScriptDependency } from '../../helpers';
import { constrainMetaModel, Constraints, split, TypeMapping, hasPreset, SplitOptions, renderJavaScriptDependency } from '../../helpers';
import { TypeScriptPreset, TS_DEFAULT_PRESET } from './TypeScriptPreset';
import { ClassRenderer } from './renderers/ClassRenderer';
import { InterfaceRenderer } from './renderers/InterfaceRenderer';
Expand All @@ -31,7 +31,7 @@ export interface TypeScriptRenderCompleteModelOptions {
/**
* Generator for TypeScript
*/
export class TypeScriptGenerator extends AbstractGenerator<TypeScriptOptions,TypeScriptRenderCompleteModelOptions> {
export class TypeScriptGenerator extends AbstractGenerator<TypeScriptOptions, TypeScriptRenderCompleteModelOptions> {
static defaultOptions: TypeScriptOptions = {
...defaultGeneratorOptions,
renderTypes: true,
Expand All @@ -53,7 +53,7 @@ export class TypeScriptGenerator extends AbstractGenerator<TypeScriptOptions,Typ

splitMetaModel(model: MetaModel): MetaModel[] {
//These are the models that we have separate renderers for
const metaModelsToSplit = {
const metaModelsToSplit: SplitOptions = {
splitEnum: true,
splitObject: true
};
Expand Down
Loading