Skip to content

refactor(openapi): cleaner approach to prepareOas helper#1312

Merged
kanadgupta merged 3 commits intonextfrom
kanad-2025-07-28/prepareOas-improvements
Jul 28, 2025
Merged

refactor(openapi): cleaner approach to prepareOas helper#1312
kanadgupta merged 3 commits intonextfrom
kanad-2025-07-28/prepareOas-improvements

Conversation

@kanadgupta
Copy link
Copy Markdown
Contributor

@kanadgupta kanadgupta commented Jul 28, 2025

🧰 Changes

as part of the work in #1313, this PR refactors our prepareOas helper (and by extension, the entire openapi family of commands) to be a little bit more conformant to the oclif command class pattern. this will clean up our debug logs a bit and should make it a bit easier to add new openapi commands going forward.

🧬 QA & Testing

no end user changes — if tests continue to pass we should be in good shape!

@kanadgupta kanadgupta added refactor Issues about tackling technical debt command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands needs-backport-to-v9 PRs that need to backported to the 9.x channel labels Jul 28, 2025
} = {},
) {
let specPath = path;
export default async function prepareOas(this: OpenAPICommands) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

args are no longer required since we can grab all of it from the this context ✨

let specPath = path;
export default async function prepareOas(this: OpenAPICommands) {
let specPath = this.args.spec;
const command = this.id satisfies `openapi ${OpenAPIAction}`;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this allows us to assert that the command id property matches predefined the openapi {action} structure... common TS + oclif w

@kanadgupta kanadgupta marked this pull request as ready for review July 28, 2025 19:03
@kanadgupta kanadgupta requested review from emilyskuo and erunion July 28, 2025 19:03

static flags = {
out: Flags.string({ description: 'Output file path to write resolved file to' }),
title: titleFlag,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the resolve command doing with this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just for consistency i've mostly had it where every command that ends up outputting a new OAS file (i.e., pretty much every command besides inspect and validate) could benefit from this flag since it allows people to set custom info.title fields on the output

@kanadgupta kanadgupta merged commit 72f7328 into next Jul 28, 2025
11 checks passed
@kanadgupta kanadgupta deleted the kanad-2025-07-28/prepareOas-improvements branch July 28, 2025 21:51
@kanadgupta
Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 10.5.0-next.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kanadgupta
Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 10.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands needs-backport-to-v9 PRs that need to backported to the 9.x channel refactor Issues about tackling technical debt released on @next released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants