Skip to content

refactor: replace Map type with Record #1173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sserrata
Copy link
Member

Summary

  • replace custom Map<T> with standard Record<string, T> for OpenAPI types

Testing

  • yarn lint
  • yarn build-packages
  • yarn test

https://chatgpt.com/codex/tasks/task_e_685ed9d1a0148323991549c0dc4f48ae

@sserrata sserrata added the chore label Jun 27, 2025
Copy link

Visit the preview URL for this PR (updated for commit afa0d49):

https://docusaurus-openapi-36b86--pr1173-77zxb08e.web.app

(expires Sun, 27 Jul 2025 18:06:15 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata sserrata self-assigned this Jun 27, 2025
@sserrata
Copy link
Member Author

Switching from a custom interface Map to TypeScript’s native Record<string, T> improves both the clarity and interoperability of the OpenAPI type definitions:

The file no longer declares its own Map type at the top; instead, each property that previously used Map now directly references Record<string, …> (see lines defining ServerObject and ComponentsObject)

Operations, parameters, callbacks, and security-related objects all now specify their mappings via Record<string, …> rather than a custom container type

Benefits

Simpler code: Removing the custom Map interface eliminates an extra abstraction layer. Contributors immediately see that these objects are simple key–value mappings, without hunting down a custom type definition.

TypeScript tooling: The built‑in Record type interacts seamlessly with the TypeScript compiler, editors, and IDEs—providing better autocomplete and error checking.

Consistency with other projects: Most TypeScript codebases rely on Record for string-keyed objects. Using the standard pattern helps new contributors understand the structure more quickly.

Overall, this change streamlines the type definitions and clarifies how the project models OpenAPI objects. The code remains fully type‑safe while benefiting from familiar, well-supported TypeScript constructs.

@sserrata sserrata merged commit f7fdb32 into PaloAltoNetworks:main Jun 27, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant