No support for APEX (Salesforce flavor of Java)
garrett-wade opened this issue · comments
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.
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.
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
Yep, I came to the same conclusion. Pulled the repo down and am adjusting the pattern in the options.
Hey @erunion, I was able to make a few edits to get this working:
-
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. -
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 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.
@erunion the pattern appended to the options would also have to be honored by Extract.extractSchemasFromCode
@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.
@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.
@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.