Want to change @JsonProperty property in the java model which is being created from TypeSpec. #4207
|
So basically as the title suggests. I looked up some decorators docs to see if I can use those to modify what property is being set in JsonProperty in the Java file for various fields. But the example used was of console.log. The only way I found to set some metadata to the decorators was through stateMap or stateSet which uses key. But I don't think any key is required in my scenario. Is there any way to change JsonProperty from the field name when creating a model ? |
Replies: 2 comments 1 reply
|
I'm sorry I don't understand what you are trying to do. Can you say more, or give an example of the output you are seeing and how you want to change it? |
|
I am not sure whether I get the question. I assume you are talking about a property with name e.g. "foo" in TypeSpec, but you want There is an Note that the latest version of the http-client-java emitter no longer use Jackson (hence no |
I am not sure whether I get the question.
I assume you are talking about a property with name e.g. "foo" in TypeSpec, but you want
@JsonProperty("bar")instead for it.There is an
@encodedNamedecorator that modifies the "wire name" (the name of the property in the JSON payload).E.g. https://github.com/Azure/typespec-azure/blob/main/packages/azure-http-specs/specs/client/naming/main.tsp#L37-L38
It means, when serialize/de-serialize for "application/json" content-type, use "wireName" as JSON property name, instead of "defaultName".
Note that the latest version of the http-client-java emitter no longer use Jackson (hence no
@JsonProperty).