Openapi-generator: [NancyFX] Name normalization breaking my toolchain

Created on 20 Jul 2018  路  3Comments  路  Source: OpenAPITools/openapi-generator

Description

In regards to class and parameter name mappings... I'd expect that if I create a JSON Schema based on a class I have in a given language (C# for example), that openapi-generator (fka swagger-codegen) would preserve the parameter names when I generate a client or server in the same language. I understand that there is a "bring your own models" option, and that works for virtually all use cases.

However, I'm in an edge case where I am having to pick apart "deep" legacy objects and create "shallow" objects to expose to the API endpoints.

My tool-chain involves:

  1. Some "automated" OpenAPI spec generation code that I use to describe the service and build the "shallow" object schemas programatically (basically replace "deep" and "list-like" members on classes with "shallow" foreign-key references)
  2. The openapi generator code to create clients and server.
  3. Server implementation code (NancyFX) that maps the "deep" legacy objects to "shallow" API objects on-the-fly.

The problem I have is that (badly named legacy) parameters having lowercase letters as their first character are getting re-normalized to uppercase, breaking my on-the-fly object mapper (parameters not found).

See here for more info: https://github.com/swagger-api/swagger-codegen/issues/8447

What I suggest is simply adding an option like "normalize-names" [true|false] to allow for my use case (rather selfish, I know), but maybe useful to others since many real-world/enterprise projects are NOT greenfield. Thoughts?

Most helpful comment

Though that is helpful, it won't help in my use case. All I need is something like

    Preserves the property names set in specification file: true | false

All 3 comments

The problem I have is that (badly named legacy) parameters having lowercase letters as their first character are getting re-normalized to uppercase, breaking my on-the-fly object mapper (parameters not found).

What about adding an option to let you choose the parameter naming? Something like the following:

        Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase)

Though that is helpful, it won't help in my use case. All I need is something like

    Preserves the property names set in specification file: true | false

Hi,

What is the status of this now ?
Thanks.

Was this page helpful?
0 / 5 - 0 ratings