Skip to content

Commit

Permalink
cyclosproject#31 unit test model referenced in oneOf in path is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
remkoboschker committed Jul 29, 2019
1 parent e00dcc9 commit c696216
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/all-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
}
}
}
},
"/test2": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"nullabe": true,
"oneOf": [
{
"$ref": "#/components/schemas/ReferencedInOneOfPath"
}
]

}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -94,6 +115,14 @@
}
}
},
"ReferencedInOneOfPath": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Containers": {
"type": "array",
"items": {
Expand Down
17 changes: 17 additions & 0 deletions test/all-types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ describe('Generation tests using all-types.json', () => {
});
});

it('ReferencedInOneOfPath model', done => {
const ref = gen.models.get('ReferencedInOneOfPath');
const ts = gen.templates.apply('model', ref);
const parser = new TypescriptParser();
parser.parseSource(ts).then(ast => {
expect(ast.imports.length).toBe(0);
expect(ast.declarations.length).toBe(1);
expect(ast.declarations[0]).toEqual(jasmine.any(InterfaceDeclaration));
const decl = ast.declarations[0] as InterfaceDeclaration;
expect(decl.name).toBe('ReferencedInOneOfPath');
expect(decl.properties.length).toBe(1);
expect(decl.properties[0].name).toBe('name');
expect(decl.properties[0].type).toBe('string');
done();
});
});

it('Container model', done => {
const container = gen.models.get('Container');
const ts = gen.templates.apply('model', container);
Expand Down

0 comments on commit c696216

Please sign in to comment.