Skip to content

Commit ee41b3f

Browse files
fix path naming for path items
1 parent 5623da5 commit ee41b3f

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/middlewares/parsers/schema.preprocessor.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,7 @@ export class SchemaPreprocessor<
735735

736736
HttpMethods.forEach((method) => {
737737
if (method in parent.object)
738-
children.push(
739-
new VisitorNode('operation', parent.object[method], [
740-
...parent.path,
741-
method,
742-
]),
743-
);
738+
children.push(VisitorNode.fromParent(parent, 'operation', method));
744739
});
745740

746741
children.push(
@@ -844,8 +839,8 @@ export class SchemaPreprocessor<
844839
return children;
845840
}
846841

847-
private getChildrenForParameterBase(
848-
parent: VisitorNode<'parameter' | 'header'>,
842+
private getChildrenForHeader(
843+
parent: VisitorNode<'header'>,
849844
): VisitorNode<any>[] {
850845
const children = [];
851846

@@ -857,16 +852,6 @@ export class SchemaPreprocessor<
857852
return children;
858853
}
859854

860-
private getChildrenForHeader(
861-
parent: VisitorNode<'header'>,
862-
): VisitorNode<any>[] {
863-
const children = [];
864-
865-
children.push(...this.getChildrenForParameterBase(parent));
866-
867-
return children;
868-
}
869-
870855
private getChildrenForMediaType(
871856
parent: VisitorNode<'mediaType'>,
872857
): VisitorNode<any>[] {
@@ -883,10 +868,19 @@ export class SchemaPreprocessor<
883868
private getChildrenForParameter(
884869
parent: VisitorNode<'parameter'>,
885870
): VisitorNode<any>[] {
871+
if (isReferenceObject(parent.object)) {
872+
throw new Error('Object should have been unwrapped.');
873+
}
874+
886875
const children = [];
887876

888-
children.push(...this.getChildrenForParameterBase(parent));
889-
children.push(VisitorNode.fromParent(parent, 'schema'));
877+
children.push(
878+
new VisitorNode('schema', parent.object.schema, [
879+
...parent.path.slice(0, parent.path.length - 1),
880+
parent.object.name,
881+
parent.object.in,
882+
]),
883+
);
890884
children.push(
891885
...VisitorNode.fromParentDict(parent, 'mediaType', 'content'),
892886
);

0 commit comments

Comments
 (0)