Skip to content
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

feat: format transform #1094

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: format transform #1094

wants to merge 6 commits into from

Conversation

LukeHagar
Copy link
Member

@LukeHagar LukeHagar commented Nov 15, 2024

This pull request introduces a new command to format OpenAPI documents and includes corresponding tests. The most important changes include adding the formatCmd command, implementing the runFormat function, and creating tests to ensure the formatting works correctly.

New command for formatting OpenAPI documents:

  • cmd/openapi/transform.go: Added the formatCmd command to the transformCmd command group, which formats an OpenAPI document to be more human-readable. [1] [2]
  • cmd/openapi/transform.go: Implemented the runFormat function to handle the logic for the new formatCmd command.

Tests for the new format command:

  • internal/transform/format_test.go: Added tests to verify the behavior of the new formatCmd command, ensuring that the formatted OpenAPI document matches the expected output.

@LukeHagar LukeHagar marked this pull request as draft November 15, 2024 04:40
@LukeHagar LukeHagar marked this pull request as ready for review November 21, 2024 13:55
var unknownOrder = []string{}

// Orders contains the order of keys for each node type
type Orders struct {
Copy link
Member

Choose a reason for hiding this comment

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

Honestly not entirely sure why this is necessary when the individual slices and their existing names are just as clear

Copy link
Member Author

Choose a reason for hiding this comment

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

It was much easier to use this when adding each level, and the logic for determining the order to use completely changed a few times as I realized some silly mistakes in the initial implementation.

Happy to simplify if needed.

Copy link
Member

@chase-crumbaugh chase-crumbaugh left a comment

Choose a reason for hiding this comment

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

Looks really great! Just needs a few basic tests

@LukeHagar
Copy link
Member Author

Added a whole document test

Copy link
Contributor

@ryan-timothy-albert ryan-timothy-albert left a comment

Choose a reason for hiding this comment

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

Looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants