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.

[BUG] Params named "default" get replaced with "_default", resulting in incompatible clients

See original GitHub issue
Description

My api has a request object that contains a key called default, however when I generate client code from this spec, it gets converted to _default. Since my api expects default, the generated client code does not work.

I’m guessing this is escaping that happens in java since default is a java keyword. Is there any way around this?

Expected generated:

export interface RbacAddRoleRequest {
    default?: boolean;

Actual generated:

export interface RbacAddRoleRequest {
    _default?: boolean;
openapi-generator version

4.0.0

OpenAPI declaration file content or url

https://gist.github.com/seanlaff/d2aef0244adeeea95c1396952b28d987

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.0.0-beta generate \
    -i /local/test.yaml \
    -g typescript-axios \
    -o /local/out/ts

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
seanlaffcommented, Jan 23, 2020

I use a dirty sed to get around this for now gsed -i 's/_default?:/default?:/' src/models/*;

2reactions
ffMathycommented, Nov 2, 2021

I switched to Autorest now. Works like a charm, and is so much more stable and reliable. It also supports way more features it seems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set default query string parameter value for webapi?
The name parameter needs to have a default value, if I use string name = "world", it seems not working and throw "errors":{"name":["The...
Read more >
Bug Patterns - Error Prone
Defaults for AutoValue Builders should be set in the factory method ... The called constructor accepts a parameter with the same name and...
Read more >
"Least Astonishment" and the Mutable Default Argument
then if default parameters were bound at function execution rather than ... Now, suppose the behaviour of defaults could be changed so that...
Read more >
Redis-specific parameters - Amazon ElastiCache for Redis
You can't change the values of any parameters in the default parameter group. ... If enabled, clients who attempt to write to a...
Read more >
Breaking changes in 7.0 | Elasticsearch Guide [7.17] | Elastic
This default limit can be changed for a particular index with the index setting ... Using the old name in new indices created...
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