question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

to_dict() of `model` should respect attribute_map

See original GitHub issue

While running to_dict method on the model attribute_map is not respected.

    attribute_map = {
        'service_name': 'serviceName',
        'service_port': 'servicePort'
    }

This results in bad yaml

  - host: example.com
    http:
      paths:
      - backend:
          service_name: example-service
          service_port: 8080
        path: /

related:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jouvecommented, May 11, 2022

instead of obj.to_dict() , I have found that ApiClient().sanitize_for_serialization(obj) does the job to remap the snake_case names to camelCase (also filtering the None fields)

1reaction
roycaihwcommented, Aug 19, 2020

This is a openapi-generator bug / intended behavior. It should be fixed in the generator

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert Django Model object to dict with all of the fields intact
If your query is Model.Objects.get() : get() will return single instance so you can direct use __dict__ from your instance.
Read more >
pandas.DataFrame.to_dict — pandas 1.5.2 documentation
Mapping subclass used for all Mappings in the return value. Can be the actual class or an empty instance of the mapping type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found