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

[BUG][PYTHON] Client response is not respecting capital letters #10469

Closed
4 of 5 tasks
gmcrocetti opened this issue Sep 24, 2021 · 5 comments
Closed
4 of 5 tasks

[BUG][PYTHON] Client response is not respecting capital letters #10469

gmcrocetti opened this issue Sep 24, 2021 · 5 comments

Comments

@gmcrocetti
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Python response containing keys in capital letters are being converted to lowercase. Therefore, schema is not being respect. I'm not sure if attribute map should be done at response time.

openapi-generator version

3.0.3

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Sample service
  version: 0.0.1
  description: response wrongly capitalized
paths:
  /foo:
    post:
      operationId: foo
      description: hello
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MyRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyResponse'
components:
  schemas:
    MyRequest:
      type: object
      properties:
        hello: 
          type: string
    MyResponse:
      type: object
      properties:
        QUICK:
          type: boolean
          readOnly: true
          default: false
        FOX:
          type: boolean
          readOnly: true
          default: false
      required:
      - QUICK
      - FOX
Generation Details

Python client was generated with default settings using the docker image provided (latest)

Steps to reproduce
  1. Call your endpoint that returns capitalized letters. Response should be something like:
{
    "QUICK": "foo",
    "FOX": "bar"
}
  1. Python client parses response above and returns all entries in lowercase.
{
    "quick": "foo",
    "fox": "bar"
}
Related issues/PRs
Suggest a fix

It's ok controlling this in a request scenario, where the arguments to your class object are all lowercase but regarding the response, I don't this this parsing as valuable as API's consumer expects to receive a response matching the schema definition, which is not happening currently.
Expected output should mimic the schema:

{
    "QUICK": "foo",
    "FOX": "bar"
}
@spacether
Copy link
Contributor

spacether commented Sep 28, 2021

This issue is very similar to #5214

@gmcrocetti
Copy link
Author

gmcrocetti commented Sep 29, 2021

This issue is very similar to #5214

@spacether , thanks a lot for your quick feedback.

Yeah, it looks like, but at the same time it doesn't. #5214 wants to customize how parameters are going to be "translated" to the client. What I'm currently seeking is that the generated Python client respect the schema at response time.

#5214 will work smoothly because foo_id will be translated to FooID at request time, instead of what will happen in my use case, where one expects KEY and gets key at response time.

Do you think it makes sense ?

@spacether
Copy link
Contributor

In my solution both the request and response stay as in spec case.

@gmcrocetti
Copy link
Author

Alright, sounds good to me. Feel free to close :). Thanks a lot

@spacether
Copy link
Contributor

Heads up there is a new client, python-experimental which uses spec naming for all endpoint parameters and model properties. It was added in: #8325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants