microsoft / kiota-typescript

TypeScript libraries for Kiota-generated API clients.
https://aka.ms/kiota/docs
MIT License
37 stars 27 forks source link

Kiota TypeScript Generates Fields and Methods with Incorrect Casing #1139

Closed zZHorizonZz closed 5 months ago

zZHorizonZz commented 6 months ago

The kiota typescript generator is producing field and method names that begin with lowercase letters, even when the corresponding definitions in the OpenAPI specification use uppercase (capital) letters. This casing discrepancy causes parsing errors because parsing seems case-sensitive, and the generated code cannot correctly match the expected data structure.

Steps to Reproduce:

  1. Define an OpenAPI Specification: Create an OpenAPI (Swagger) specification with entities containing properties and/or methods starting with capital letters. For example:

    components:
     schemas:
       MyObject:
         type: object
         properties:
           ImportantValue:
             type: string
           RequestMethod:
             type: string 
  2. Generate TypeScript Code: Use the kiota generator to create corresponding typeScript models and/or client code from the specification.

  3. Inspect Generated Code: Examine the generated TypeScript code. Observe that the field ImportantValue and method RequestMethod might be incorrectly generated as importantValue and requestMethod, respectively.

  4. Attempt Data Parsing: Try to parse a JSON response conforming to the original OpenAPI specification using the generated TypeScript models. Parsing errors are likely to occur.

Expected Behavior:

The kiota typescript generator should preserve the casing of fields and methods as defined in the OpenAPI specification. In the example above, the generated code should include ImportantValue and RequestMethod with their correct capitalization.

Potential Solutions:

zZHorizonZz commented 5 months ago

Closing in favor of https://github.com/microsoft/kiota/issues/4479