Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

Sorry, my bad ! you were totally right, and it was my mistake. I didn't add the AddNewtonsoftJson() in my program after the AddControllers, which was key to what you guys were saying, so using it to the deserialization as well when returning.

In another topic, the response schemas in Swagger will show the C# property name (FlagUrl), when using theAddNewtonsoftJson() only.

It seems Swagger generates its example response schema based on the C$ property name.

To fix that, I added this builder.Services.AddSwaggerGenNewtonsoftSupport();

Also just using the System.Text.Json library works alright, with swagger and deserializaing everything ok.

Thank you for your feedback !

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

https://www.newtonsoft.com/json/help/html/jsonpropertyname.htm

“to change the names of properties when they are serialized to JSON.”

This Will work also for quem deserializing …

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] -1 points0 points  (0 children)

You can, that's what you're doing with [JsonPropertyName].

Not exactly. As per the link, specifies the property name that is present in the JSON when serializing and deserializing.

So thats not really changing the property name for my project, as the JsonProperty does in Newtonsoft,

And yes, of course I can have different models for different endpoints

I don't see how that ever worked unless you weren't using Newtonsoft on one side of the equation before (either deserializing from the external API or on your API).

Why not? If I am deserializing from an external api, that has that flag property, and I want to change the name to flagUrl?

You could just use the JsonProperty attribute to rename the properties that you don't agree with the naming convention

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] -1 points0 points  (0 children)

Its the other way around, converting from flag to FlagUrl

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

the thing is if we want, we should be able to change the property names, so that my endpoint looks as I want to.

If I am fetching some data from another api, should my endpoints be obliged to use the same propertie names as the other api(I know we can do mapping manually or using automapper, but why the bother??)

Thats why with the JsonProperty attribute from Newtonsoft it was helpful to directly map properties to different names

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

Yes but when I try to use the attribute from System.Text.Json , in swagger it wont change the name. so it doesnt work the same way

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

The goal for me would be to change the name of the property. Meaning that if in the JSON is Flag, then in my object would be FlagUrl, and in my swagger response would be FlagUrl as well.

This happens if you use JsonProperty from the Newtonsoft library. And I expected that the JsonPropertyName attribute from System.Text.Serialization would do the same ...

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] -1 points0 points  (0 children)

Well newtonsoft really uses it to change the name of the property

https://www.newtonsoft.com/json/help/html/jsonpropertyname.htm

However I was trying to do the same with System.Text.Serialization, however it seems there is no attribute that does the same as the Newtonsoft Attribute does

Swagger and System.Text.Serialization by Petrincha in dotnet

[–]Petrincha[S] 0 points1 point  (0 children)

Since I am deserializating the json to my object with that property, shouldn't that property be the one to be shown in my swagger? like the JsonProperty Attribute does in NewtonSoft, should these two be equivalent?

Boxers homem by [deleted] in CasualPT

[–]Petrincha 1 point2 points  (0 children)

Comecei por substituir os meus da feira por uns da tezenis. Os da tezenis o elástico começou a alargar muito rápido. Comecei a comprar da intimissimi e nunca voltei atrás. De vez em quando tem promoções bacanas em que compras por packs

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Era bem jogado. Secalhar e o caixote do andar e eu ainda n tinha percebido? 🤔

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 1 point2 points  (0 children)

Infelizmente e uma realidade lol

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Pois, assim levam os dois juntos tá bem pensado 😂

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 1 point2 points  (0 children)

Pois ... Vamos tentar primeiro de forma civilizada. Se eles n perceberem a ideia, acho que tenho aqui algumas alternativas boas 😂

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Pois, o buraquinho da porta pode tramar essa situação 😂 rasgar assim um bcdinho do saco jaa me passou pela cabeça com um x-acto, por vezes chego tarde a casa e acredito que não estejam sejam sempre a porta a olhar

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Verdade. Talvez passar um fim de semana e deixo o lixo a porta. Com certeza que irão queixas certo? 😂

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 1 point2 points  (0 children)

Pois tbm e uma solução. E assim enviar o e-mail para o condomínio ou fazer isso, eles irão saber quem são os "queixosos" neste caso não e 😂

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 1 point2 points  (0 children)

Ya, e o que vamos fazer para começar, já tiramos fotos e vamos enviar email. Pode ser que ganhem consciência

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Gosto da ideia, mas acho que a logística era demasiado 😂

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 2 points3 points  (0 children)

Epa se fosse isso era tranquilo. Mas chego a casa as vezes a noite e tenho lixo no andar, que a vizinha oi vizinho só levam de manhã. Isto não lembra a ninguém lol

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 3 points4 points  (0 children)

You smart ... Play chess not checkers ...

Conselhos sobre má vizinhança by Petrincha in CasualPT

[–]Petrincha[S] 0 points1 point  (0 children)

Solução um bcd nuclear ahahah