Skip to content

Commit 26d2cfa

Browse files
committed
test(allOf): add comprehensive tests for allOf additionalProperties: false fix
- Add OpenAPI 2.0 test specification with allOf + additionalProperties: false schema - Add 2.0.x test case to validate fix behavior across all parser versions - Update snapshots for all parsers showing clean intersection types (Foo & {}) - Validates that empty objects with additionalProperties: false in allOf no longer generate [key: string]: never signatures
1 parent 1f474f1 commit 26d2cfa

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed

packages/openapi-ts-tests/test/2.0.x.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ describe(`OpenAPI ${version}`, () => {
4545
};
4646

4747
const scenarios = [
48+
{
49+
config: createConfig({
50+
input: 'additional-properties-false.json',
51+
output: 'additional-properties-false',
52+
}),
53+
description: 'forbids arbitrary properties on objects',
54+
},
4855
{
4956
config: createConfig({
5057
input: 'additional-properties-true.json',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
export * from './types.gen';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
export type Foo = {
4+
foo: string;
5+
};
6+
7+
export type Bar = Foo & {};
8+
9+
export type Baz = Foo & {
10+
bar: string;
11+
};
12+
13+
export type ClientOptions = {
14+
baseUrl: string;
15+
};

packages/openapi-ts-tests/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export type Foo = {
44
foo: string;
55
};
66

7-
export type Bar = Foo & {
8-
[key: string]: never;
9-
};
7+
export type Bar = Foo & {};
108

119
export type Baz = Foo & {
1210
bar: string;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "OpenAPI 2.0 additional properties false example",
5+
"version": "1"
6+
},
7+
"definitions": {
8+
"Foo": {
9+
"required": ["foo"],
10+
"type": "object",
11+
"properties": {
12+
"foo": {
13+
"type": "string"
14+
}
15+
},
16+
"additionalProperties": false
17+
},
18+
"Bar": {
19+
"allOf": [
20+
{
21+
"$ref": "#/definitions/Foo"
22+
},
23+
{
24+
"type": "object",
25+
"additionalProperties": false
26+
}
27+
]
28+
},
29+
"Baz": {
30+
"allOf": [
31+
{
32+
"$ref": "#/definitions/Foo"
33+
},
34+
{
35+
"required": ["bar"],
36+
"type": "object",
37+
"properties": {
38+
"bar": {
39+
"type": "string"
40+
}
41+
},
42+
"additionalProperties": false
43+
}
44+
]
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)