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

Default values in the OpenAPI specification is not properly added in the generated code #6948

Closed
TharmiganK opened this issue Sep 2, 2024 · 1 comment · Fixed by ballerina-platform/openapi-tools#1767
Assignees
Labels

Comments

@TharmiganK
Copy link
Contributor

TharmiganK commented Sep 2, 2024

Description:

$Subject

Identified from: #6906

Steps to reproduce:

Please use the following OpenAPI specification to reproduce the issue:

openapi: 3.0.1
info:
  title: Service Openapi Yaml
  version: 0.0.0
servers:
- url: "http://{server}:{port}/"
  variables:
    server:
      default: localhost
    port:
      default: "8080"
paths:
  /albums/{id}:
    get:
      operationId: getAlbumsId
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
components:
  schemas:
    Album:
      required:
      - author
      - title
      type: object
      properties:
        iid:
          type: integer
          format: int64
          default: -1
        title:
          type: string
        author:
          type: string
        genre:
          allOf:
          - $ref: '#/components/schemas/Genre'
          default:
            name: Unknown
            description: Unknown
      additionalProperties: false
    Genre:
      required:
      - description
      - name
      type: object
      properties:
        name:
          type: string
        description:
          type: string
      additionalProperties: false

The generated type look like this:

public type Album record {|
    int iid = "-1";
    string title;
    string author;
    Genre genre = "{"name":"Unknown","description":"Unknown"}";
|};

Affected Versions:

Ballerina SwanLake Update 10(2201.10.x)

Copy link

github-actions bot commented Sep 5, 2024

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.

@TharmiganK TharmiganK added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant