Skip to content

refactor(theme): clean up type definitions #1172

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

  • reduce custom Map usages in theme package
  • extend Docusaurus DocFrontMatter instead of redefining
  • drop unused types

Testing

  • yarn lint
  • yarn test
  • yarn build-packages

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

@sserrata sserrata self-assigned this Jun 27, 2025
@sserrata sserrata added the chore label Jun 27, 2025
Copy link

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

https://docusaurus-openapi-36b86--pr1172-jb9ezfh5.web.app

(expires Sun, 27 Jul 2025 17:39:57 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata
Copy link
Member Author

sserrata commented Jun 27, 2025

The “Refactor theme types” commit removes a custom Map interface and switches to the built‑in Record type. The earlier implementation defined interface Map { [key: string]: T; }, which essentially mirrored the standard Record<string, T> utility and could be confused with JavaScript’s Map object.

After refactoring, the schema definitions directly reference Record:

  properties?: Record<string, SchemaObject>;
  ...
  mapping?: Record<string, string>;

The component using these types was updated accordingly:

  param: {
    description: string;
    example: any;
    examples: Record<string, ExampleObject>;
    ...
  };

Switching to Record eliminates redundant custom types and avoids name clashes with the native Map class. It also aligns with the project’s goal of reusing existing Docusaurus types, as reflected in the updated DocFrontMatter definition:

export interface DocFrontMatter extends DocusaurusDocFrontMatter {
  /** Provides OpenAPI Docs with a reference path to their respective Info Doc */
  info_path?: string;
}

Overall, the change simplifies type definitions and makes them clearer for anyone already familiar with TypeScript’s built‑in utilities. Using Record communicates that these objects behave like plain key/value maps with no custom behavior, making the code easier to read and maintain.

@sserrata sserrata merged commit 86e0613 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