Skip to content
New issue

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

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

Already on GitHub? # to your account

chore(30019): Split the openAPI file #856

Merged
merged 9 commits into from
Mar 20, 2025
Merged

Conversation

vanch3d
Copy link
Contributor

@vanch3d vanch3d commented Mar 18, 2025

See https://hivemq.kanbanize.com/ctrl_board/57/cards/30019/details/

The PR splits the original single YAML document into a structured multi-files system.

Out-of-scope

  • IntelliJ (backend) and WebStorm or VSCode (frontend) are using different linting processes for "cleaning" YAML documents and commits will result in changes that are purely aesthetic. A common linting set of rules should be added to the OpenAPI "repo".,

Edge OpenAPI Specifications

Structure

The main document has been split from the original source in order to reduce the size of a single document and to highlight individual points of concern.

The original split was done automatically (using redocly see below) and the files reflects the automation.

openAPI             
├── README.md
├── openapi.yaml        // root document of the OpenAPI specs
├── paths               // list of path files, organised by their route
│   ├── api_v1_auth_authenticate.yaml
│   ├── api_v1_auth_refresh-token.yaml
│   └── ...
│
└── components          // list of reusable definitions, grouped by type
    ├── headers
    │   ├── ETag.yaml
    │   └── ...
    ├── parameters
    │   ├── CombinerId.yaml
    │   └── ...
    ├── schemas
    │   ├── Adapter.yaml
    │   └── ...
    └── ...

There is no reason to maintain such naming convention as we manually add or edit the source.

Usage

The redocly library is used to manage the OpenAPI specs, stored as a split document.

Bundle

Some of the tools handling OpenAPi will be working fine with a split document.
If not, consider bundling it into a single YAML file, using the following command:

redocly split  <source to file>/openAPI.yaml --outDir <destination folter>/

Make sure NOT to commit your bundled document along the split origin; we need to ensure a single source of truth.

Split

To reverse the merge operation and create a split document, the following command will deliver:

 redocly bundle <path to source>/openapi.yml -o <path to dest>/hivemq-edge-openapi-SNAPSHOT.yaml

GitHub guidelines

  • The OpenAPI specs define in this document is the only source of truth of the Edge REST API.
  • Any change to the document MUST be done on a new clean PR
  • Any change to the document MUST be reviewed and approved by both backend and frontend
  • Changes to either backend or frontend code MUST NOT be added to the PR proposing the modifications of the specs

@vanch3d vanch3d self-assigned this Mar 18, 2025
@cla-bot cla-bot bot added the cla-signed label Mar 18, 2025
@vanch3d vanch3d requested a review from codepitbull March 18, 2025 12:29
@vanch3d
Copy link
Contributor Author

vanch3d commented Mar 18, 2025

See ext/openAPI/README.md

Copy link
Contributor Author

@vanch3d vanch3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also in favour of removing the ext/openAPI/hivemq-edge-openapi-master.yaml file, so that we don't maintain two documents that might end up diverging

Copy link
Contributor

@codepitbull codepitbull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one.
I ran tests locally and all looks good.

@vanch3d vanch3d force-pushed the chore/30019-split-openAPI branch from e53cbd5 to 0b6481b Compare March 20, 2025 17:26
@vanch3d vanch3d merged commit b4b5d6b into master Mar 20, 2025
10 checks passed
@vanch3d vanch3d deleted the chore/30019-split-openAPI branch March 20, 2025 18:22
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants