Skip to content

Conversation

@isha689
Copy link
Contributor

@isha689 isha689 commented Nov 22, 2022

Fixes

  • PHP open api code generation for list operation
  • Need feedbacks on PHP code
  • Unit test will be added in next iteration for list operations
  • Comments resolution from previous PR
  • Constructor uri resolved for list files

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • Run make test-docker
  • Verify affected language:
    • Generate twilio-go from our OpenAPI specification using the build_twilio_go.py using python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go and inspect the diff
    • Run make test in twilio-go
    • Create a pull request in twilio-go
    • Provide a link below to the pull request
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please create a GitHub Issue in this repository.

}

private APIResources processCodegenOperations(List<CodegenOperation> opList) {
return new PHPAPIResourceBuilder(new PHPAPIActionTemplate(this), opList, this.allModels)
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer CamelCase for Php and Api. Makes reading the name easier.

return new PHPAPIResourceBuilder(new PHPAPIActionTemplate(this), opList, this.allModels)
.apiPath()
.additionalProps(directoryStructureService)
.template()
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming is too generic. What does apiPath? Return the path, build the path, update the path? Same applies for the other names.

public OperationsMap postProcessOperationsWithModels(final OperationsMap objs, List<ModelMap> allModels) {
final OperationsMap results = super.postProcessOperationsWithModels(objs, allModels);
final List<CodegenOperation> opList = directoryStructureService.processOperations(results);
APIResources apiResources = processCodegenOperations(opList);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how clean this is. Should extend the refactoring to Node so we can see how this limits duplication as part of this review.

public APIResourceBuilder operations(ISchemaResolver<CodegenParameter> codegenParameterIResolver) {
this.codegenOperationList.stream().forEach(codegenOperation -> {
codegenOperation.pathParams = codegenOperation.pathParams.stream().map(item ->
codegenParameterIResolver.resolve(item)).collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean to resolve a parameter?


import static com.twilio.oai.common.ApplicationConstants.PATH_SEPARATOR_PLACEHOLDER;

public class APIResources {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

public final static String META_LIST_PARAMETER_KEY = "x-list-parameters";
public final static String META_CONTEXT_PARAMETER_KEY = "x-context-parameters";

protected IAPIActionTemplate phpTemplate;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be called php.

Comment on lines 8 to 12
public final static String TEMPLATE_TYPE_LIST = "list";
public final static String TEMPLATE_TYPE_CONTEXT = "context";
public final static String TEMPLATE_TYPE_OPTIONS = "options";
public final static String TEMPLATE_TYPE_INSTANCE = "instance";
public final static String TEMPLATE_TYPE_PAGE = "page";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be defined in a non-php context?

Comment on lines 22 to 26
codegen.apiTemplateFiles().clear();
codegen.apiTestTemplateFiles().clear();
codegen.modelTestTemplateFiles().clear();
codegen.apiDocTemplateFiles().clear();
codegen.modelDocTemplateFiles().clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the codegen adapter already doing this?


private Map<String, List<String>> mapping() {
return Map.ofEntries(
new AbstractMap.SimpleEntry<>("list", Arrays.asList("list.mustache", "List.php")),
Copy link
Contributor

Choose a reason for hiding this comment

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

These keys are already defined elsewhere.

// Path Solution
$this->solution = ['accountSid' => $accountSid, 'callSid' => $callSid, 'sid' => $sid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Calls/' . \rawurlencode($callSid) . '/Notifications/' . \rawurlencode($sid) . '.json';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not generic to all contexts.

@sonarqubecloud
Copy link

[twilio-oai-generator-php] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 196 Code Smells

0.0% 0.0% Coverage
20.6% 20.6% Duplication

@sonarqubecloud
Copy link

[twilio-oai-generator-java] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

[twilio-oai-generator-node] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

[twilio-oai-generator-go] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@isha689 isha689 merged commit e3b8451 into main Nov 23, 2022
@isha689 isha689 deleted the php_open_api_generator branch November 23, 2022 10:29
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.

5 participants