Skip to content

Commit c91200e

Browse files
authored
fix: Allow components to have dots in their names (#151)
* Allow components to have dots in their names * Update second usage of the dot pattern * Add test
1 parent 5f046e0 commit c91200e

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

plugins/typescript/src/core/getParamsGroupByType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getParamsGroupByType = (
2525
if (isReferenceObject(p)) {
2626
const schema = get(
2727
components,
28-
p.$ref.replace("#/components/", "").replace("/", ".")
28+
p.$ref.replace("#/components/", "").split("/")
2929
);
3030
if (!schema) {
3131
throw new Error(`${p.$ref} not found!`);

plugins/typescript/src/core/isRequestBodyOptional.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,33 @@ describe("isRequestBodyOptional", () => {
110110
})
111111
).toBe(false);
112112
});
113+
114+
it("should resolve with dots in names", () => {
115+
expect(
116+
isRequestBodyOptional({
117+
requestBody: {
118+
$ref: "#/components/requestBodies/Foo.Request",
119+
},
120+
components: {
121+
requestBodies: {
122+
"Foo.Request": {
123+
content: {
124+
"application/json": {
125+
schema: {
126+
type: "object",
127+
properties: {
128+
foo: {
129+
type: "string",
130+
},
131+
},
132+
required: ["foo"],
133+
},
134+
},
135+
},
136+
},
137+
},
138+
},
139+
})
140+
).toBe(false);
141+
});
113142
});

plugins/typescript/src/core/isRequestBodyOptional.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const isRequestBodyOptional = ({
4141

4242
const schema: RequestBodyObject | ReferenceObject = get(
4343
components,
44-
requestBody.$ref.replace("#/components/", "").replace("/", ".")
44+
requestBody.$ref.replace("#/components/", "").split("/")
4545
);
4646

4747
if (!schema) {

0 commit comments

Comments
 (0)