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: method validation step in OAS #6038

Merged
merged 12 commits into from
Jan 30, 2025

Conversation

mingxuanzhangsfdx
Copy link
Member

What does this PR do?

This PR adds an extra step in the processor to validate the methods after OAS generation, including

  1. All eligible methods are generated in OAS
  2. Ineligible methods are not generated
  3. Each method contains exactly one operation

What issues does this PR fix or reference?

@W-17654638@

Functionality Before

methods are not validated in the process

Functionality After

Validation of the methods is implemented.

@mingxuanzhangsfdx mingxuanzhangsfdx marked this pull request as ready for review January 28, 2025 23:43
@mingxuanzhangsfdx mingxuanzhangsfdx requested a review from a team as a code owner January 28, 2025 23:43

export interface ProcessorInputOutput {
yaml: string;
errors?: ISpectralDiagnostic[];
eligibilityResult: ApexClassOASEligibleResponse;
Copy link
Member Author

Choose a reason for hiding this comment

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

I found it convenient to pass in the context we need through this structure. But it seems that the data in the structure tends to be writable but the two objects I added are read-only. So open to opinions.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mingxuanzhangsfdx you can alter the type with Readonly<T>

@peternhale peternhale removed the request for review from diyer January 29, 2025 15:11
@@ -22,7 +22,7 @@ export class OasValidationStep implements ProcessorStep {
input.errors = result;
});

// Since this step doesn't perform convertions we return the input for future processing
// Since this step doesn't perform conversions we return the input for future processing
Copy link
Contributor

Choose a reason for hiding this comment

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

Any errors found should be added to the input.errors.


export interface ProcessorInputOutput {
yaml: string;
errors?: ISpectralDiagnostic[];
eligibilityResult: ApexClassOASEligibleResponse;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mingxuanzhangsfdx you can alter the type with Readonly<T>

@@ -58,7 +58,7 @@ describe('MetadataOrchestrator', () => {
];
jest.spyOn(orchestrator, 'validateEligibility').mockResolvedValue(mockResponse);
await expect(orchestrator.validateMetadata(editorStub.document.uri, true)).rejects.toThrow(
'Method someMethod is not eligible for OpenAPI Document creation. It is not annotated with @AuraEnabled or has wrong access modifiers.'
'Method someMethod is not eligible for OpenAPI Document creation. It is not annotated with an http annotator or has wrong access modifiers.'
Copy link
Contributor

Choose a reason for hiding this comment

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

@mingxuanzhangsfdx Thanks for catching the AuraEnabled message! I believe this message should be more general. Http annotations are the current ones, but I imagine AuraEnabled will eventually return. What do think about referring the user to current documentation regarding what makes an Apex method eligible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I just noticed that the sentence is only used when one method is selected for generation. Since it is not required by TDX, I guess we can leave it for now?

@mingxuanzhangsfdx mingxuanzhangsfdx merged commit 3cc1b89 into feat/apex-oas Jan 30, 2025
6 checks passed
@mingxuanzhangsfdx mingxuanzhangsfdx deleted the mz/method-validation-step branch January 30, 2025 18:36
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.

2 participants