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

No support for APEX (Salesforce flavor of Java) #603

Closed
garrett-wade opened this issue Feb 21, 2022 · 9 comments · Fixed by #614
Closed

No support for APEX (Salesforce flavor of Java) #603

garrett-wade opened this issue Feb 21, 2022 · 9 comments · Fixed by #614
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@garrett-wade
Copy link

Our company builds APIs on Salesforce and as a result our source code is in APEX. I have done some due diligence and it seems the CLI does not support APEX files. APEX files have a file extension of ".cls" and even when I directly try to create the file via swagger-inline with the following snippet npx swagger-inline "force-app/main/default/classes/*.cls" --base 'test.json' the path is not added to the OAS. This would be a huge lift if we are able to support APEX and APIs built on Salesforce. Thank you.

@garrett-wade
Copy link
Author

Was able to get the following error: Cannot find language definition for 'force-app/main/default/classes/controllers/CustomMetadataController.cls' and the comment style for this class is the same as java */ in face it works if I change the file extension to Java.

@erunion
Copy link
Member

erunion commented Feb 22, 2022

Seems that this is happening because CJS isn't recognized by the comment-patterns library that we use: https://github.com/nknapp/comment-patterns/tree/master/languages/patterns

@erunion erunion added bug Something isn't working help wanted Extra attention is needed labels Feb 22, 2022
@garrett-wade
Copy link
Author

Yep, I came to the same conclusion. Pulled the repo down and am adjusting the pattern in the options.

@garrett-wade
Copy link
Author

garrett-wade commented Feb 23, 2022

Hey @erunion, I was able to make a few edits to get this working:

  1. Edit the glob to be: let pathGlob = '**/*.cls'; in the oas utils.js file. It would be nice to be able to specify the glob at the command line.

  2. Edit the Extract.extractEndpointsFromCode method in the extract.js file to add a pattern to the options as seen below:

 options["pattern"] = {
        name: 'Apex',
        nameMatchers: ['.cls'],
        singleLineComment: [{ start: '//' }],
        multiLineComment: [{ start: '/*', middle: '', end: '*/'}]
}

It would be nice to be able to specify the glob and the pattern from the command line.

Additionally, we have a deprecated file in our repo that looks like this:

/**
 * @deprecated Replaced with CRDebtsExcluder service
 */
public inherited sharing class DebtDeduplicationService {
}

This file causes an unable to recognize language error. In the short-term I was able to ignore the error, but this use case may be something to solve for in the error handling.

Thank you

@erunion erunion added the enhancement New feature or request label Feb 23, 2022
@erunion erunion self-assigned this Feb 23, 2022
@garrett-wade
Copy link
Author

garrett-wade commented Feb 23, 2022

@erunion Any thoughts on a timeline for this enhancement. Kicking off an enterprise project 3/1 with ReadMe and would love to build this into our CI/CD pipeline.

@garrett-wade
Copy link
Author

@erunion the pattern appended to the options would also have to be honored by Extract.extractSchemasFromCode

@erunion
Copy link
Member

erunion commented Feb 24, 2022

@garrett-wade We're currently locked up on some large projects and don't have the bandwidth for at least another month or two but am always open to accepting a pull request if you'd like to take stab at it.

@garrett-wade
Copy link
Author

@erunion I the following PR https://github.com/readmeio/swagger-inline/pull/249 to added pattern support to swagger-inline as this will be a dependency for the changes to resolve this enhancement.

@erunion
Copy link
Member

erunion commented Mar 2, 2022

@garrett-wade You swagger-inline changes have been published to https://github.com/readmeio/oas/releases/tag/17.8.0. I also added a new --pathGlob and --pattern argument to the CLI for you too. Hope it all works out and thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants