ballerina-platform / ballerina-library

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

OpenAPI sanitize option makes the camel case part in a string with special characters to lower case #6922

Closed TharmiganK closed 2 months ago

TharmiganK commented 2 months ago

Description:

The --use-sanitized-oas option is making the camel case part in a type name with special character to lower case.

AlbumNew_one -> AlbumnewOne

Identified from: https://github.com/ballerina-platform/ballerina-library/issues/6906

Steps to reproduce:

Please use the following OpenAPI specification to reproduce the issue:

openapi: 3.0.1
info:
  title: Api
  version: 0.1.0
servers:
- url: "{server}:{port}/api"
  variables:
    server:
      default: http://localhost
    port:
      default: "9999"
paths:
  /albums:
    get:
      operationId: getAlbums
      description: Get albums by genre
      parameters:
      - name: genre
        in: query
        required: true
        description: Album genre
        schema:
          type: string
      - name: API-VERSION
        in: header
        description: API Version
        schema:
          $ref: '#/components/schemas/VERSION'
          default: V1
      responses:
        "200":
          description: Albums found
          headers:
            req-id:
              required: true
              description: Request ID
              schema:
                type: integer
                format: int64
            api-version:
              required: true
              description: API Version
              schema:
                type: string
            session-id:
              required: true
              description: Session ID
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AlbumNew_one'
components:
  schemas:
    AlbumNew_one:
      required:
      - artist
      - genre
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: Album ID
        name:
          type: string
          description: Album name
        artist:
          type: string
          description: Album artist
        genre:
          type: string
          description: Album genre
      additionalProperties: false
    VERSION:
      type: string
      description: API Version
      enum:
      - V1
      - V2
$ bal openapi -i openapi.yaml --mode client --use-sanitize-oas

Generated type name:

public type AlbumnewOne record {|
    # Album ID
    string id;
    # Album name
    string name;
    # Album artist
    string artist;
    # Album genre
    string genre;
|};

Affected Versions:

Ballerina SwanLake Update 10(2201.10.x)

github-actions[bot] commented 2 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.