Skip to content

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
@sserrata sserrata deleted the codex/clean-up-type-definitions-in-docusaurus-theme-openapi-docs branch June 30, 2025 18:25
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