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

[1.8.x]Add support for union type request body mapping to Ballerina to OpenAPI spec generation #1544

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

lnash94
Copy link
Member

@lnash94 lnash94 commented Sep 21, 2023

Purpose

Fix #ballerina-platform/ballerina-library#5233
Fix https://github.com/wso2-enterprise/internal-support-ballerina/issues/443
Implement the union-type mapping for request body in OpenAPI spec generation

Automation tests

  • Unit tests - added

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

❗ No coverage uploaded for pull request base (1.8.x@77c5acf). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head deb8b15 differs from pull request most recent head 127fc07. Consider uploading reports for the commit 127fc07 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##             1.8.x    ballerina-platform/openapi-tools#1544   +/-   ##
========================================
  Coverage         ?   79.55%           
  Complexity       ?     1763           
========================================
  Files            ?      124           
  Lines            ?    10086           
  Branches         ?     1673           
========================================
  Hits             ?     8024           
  Misses           ?     1479           
  Partials         ?      583           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lnash94 lnash94 marked this pull request as ready for review September 21, 2023 13:57
@lnash94 lnash94 changed the title [1.8.x]Add support for union type request body mapping in the Ballerina to OpenAPI spec generation [1.8.x]Add support for union type request body mapping to Ballerina to OpenAPI spec generation Sep 21, 2023
@lnash94 lnash94 requested a review from dilanSachi September 21, 2023 14:15
@sonarqubecloud
Copy link

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

Copy link
Contributor

@TharmiganK TharmiganK left a comment

Choose a reason for hiding this comment

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

LGTM

@lnash94 lnash94 merged commit e0cb2e9 into ballerina-platform:1.8.x Sep 26, 2023
3 checks passed
Comment on lines +245 to +255
IncompatibleResourceDiagnostic error = new IncompatibleResourceDiagnostic(
DiagnosticMessages.OAS_CONVERTOR_116, payloadNode.location(),
String.valueOf(payloadNode.kind()));
diagnostics.add(error);
break;
}
} else {
//Warning message for unsupported request payload type in Ballerina resource.
IncompatibleResourceDiagnostic error = new IncompatibleResourceDiagnostic(
DiagnosticMessages.OAS_CONVERTOR_116, payloadNode.location(), payloadNode.toSourceCode().trim());
diagnostics.add(error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we are using the same error, but with two different properties of the payload (payload kind at L247 and, payload node itself at L254). Is that intentional?

operationAdaptor.getOperation().setRequestBody(bodyParameter);
}
}

private void addConsumes(OperationAdaptor operationAdaptor, RequestBody bodyParameter, String applicationType) {
String type = applicationType.split("/")[1];
private void addConsumes(OperationAdaptor operationAdaptor, RequestBody bodyParameter, String applicationType,
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the purpose of this util?

content.addMediaType(mimeType, media);
} else if (typeDescriptorNode.kind() == SyntaxKind.BYTE_TYPE_DESC) {
StringSchema byteSchema = new StringSchema();
byteSchema.setFormat("byte");
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we reuse our predefined constant for "byte" in here?

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