OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.54k stars 6.27k forks source link

[BUG][haskell-http-client] --name-mappings is not applied to property names #18943

Closed valpackett closed 1 week ago

valpackett commented 2 weeks ago
Description

With a field that's named _ (single underscore), the Haskell http-client generator generates a name collision due to stripping underscores without considering this:

-- * TestGet200Response

-- | 'testGet200ResponseOuter' Lens
testGet200ResponseOuterL :: Lens_' TestGet200Response (Maybe TestGet200ResponseOuter)
testGet200ResponseOuterL f TestGet200Response{..} = (\testGet200ResponseOuter -> TestGet200Response { testGet200ResponseOuter, ..} ) <$> f testGet200ResponseOuter
{-# INLINE testGet200ResponseOuterL #-}

-- * TestGet200ResponseOuter

-- | 'testGet200ResponseOuter' Lens
testGet200ResponseOuterL :: Lens_' TestGet200ResponseOuter (Maybe [Text])
testGet200ResponseOuterL f TestGet200ResponseOuter{..} = (\testGet200ResponseOuter -> TestGet200ResponseOuter { testGet200ResponseOuter, ..} ) <$> f testGet200ResponseOuter
{-# INLINE testGet200ResponseOuterL #-}

And name-mappings don't apply so that workaround is not available.

openapi-generator version

989a79811a5cae2b10e07e6c4d5261af3da1e39d

OpenAPI declaration file content or url
openapi: '3.0.0'
info:
  version: 1.0.0
  title: test
paths:
  /test:
    get:
      summary: sample
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  outer:
                    type: object
                    properties:
                      '_':
                        type: array
                        items:
                          type: "string"
Generation Details
java -jar /home/val/.m2/repository/org/openapitools/openapi-generator-cli/7.7.0-SNAPSHOT/openapi-generator-cli-7.7.0-SNAPSHOT.jar generate -i spec.yaml -o out -g haskell-http-client --name-mappings _=underscore
Steps to reproduce

Try the spec from above.

Related issues/PRs
Suggest a fix

Will look into it myself