Skip to content

Commit

Permalink
fix: Fixed a bug where properties with '.' as a key were not referenc…
Browse files Browse the repository at this point in the history
…ed (#64)
  • Loading branch information
Himenon committed Nov 10, 2021
1 parent f305896 commit d93333c
Show file tree
Hide file tree
Showing 3 changed files with 2,102 additions and 660 deletions.
1 change: 1 addition & 0 deletions src/internal/OpenApiTools/components/PathItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export const generateStatements = (
),
);
}
// TODO Check usage
// if (pathItem.parameters) {
// Parameters.generateNamespaceWithList(entryPoint, currentPoint, store, factory, pathItem.parameters, context);
// }
Expand Down
6 changes: 5 additions & 1 deletion src/internal/ResolveReference/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export { OpenApi };

export type ObjectLike = { [key: string]: any };

const escapeFromJsonCyclic = (obj: any) => JSON.parse(JSON.stringify(obj));

const isObject = (value: any): value is ObjectLike => {
return !!value && value !== null && !Array.isArray(value) && typeof value === "object";
};
Expand Down Expand Up @@ -89,7 +91,9 @@ const resolveLocalReference = (entryPoint: string, currentPoint: string, obj: an
`This is an implementation error. Please report any reproducible information below.\nhttps://github.com/Himenon/openapi-typescript-code-generator/issues/new/choose\n`,
);
}
return DotProp.get(rootSchema, ref.path.replace(/\//g, "."));
// "." in the key
const escapedPath = ref.path.replace(/\./g, "\\.").replace(/\//g, ".");
return escapeFromJsonCyclic(DotProp.get(rootSchema, escapedPath));
}
return obj;
}
Expand Down
Loading

0 comments on commit d93333c

Please sign in to comment.