ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Ballerina type generated for an array of multiple member types is wrong #6708

Closed TharmiganK closed 3 months ago

TharmiganK commented 4 months ago

Description:

The Ballerina type generated for a schema which represents an array of multiple member types does not have the proper parentheses to represents the union type.

Steps to reproduce:

Use the following OpenAPI spec to generate the client/service:

openapi: 3.0.1
info:
  title: SocialMedia
  version: 0.1.0
servers:
- url: "http://{server}:{port}/socialMedia/v1"
  variables:
    server:
      default: localhost
    port:
      default: "8080"
paths:
  /test:
    get:
      responses:
        "200":
          description: Ok
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                  - type: string
                  - type: integer
                  - type: object
                    properties:
                      name:
                        type: string
                      age:
                        type: integer

The generated return type has the following format: string|int|record {string name?; int age?;}[]|error but it should be (string|int|record {string name?; int age?;})[]|error.

Affected Versions:

Ballerina SwanLake Update 9 (2201.9.x)

github-actions[bot] commented 3 months ago

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.