Git Product home page Git Product logo

Comments (5)

christianhelle avatar christianhelle commented on July 21, 2024 1

I just experimented a bit with the Swagger Petstore v3 example

$  curl -X 'POST' 'https://petstore3.swagger.io/api/v3/pet/1?NaMe=Velociraptor&StAtUS=Available'

returns

No name provided

I tried it out in Refit and can see that using [AliasAs()] in the interface works

[Get("/pet/{petId}")]
Task<Pet> GetPetById(long petId);

[Post("/pet/{petId}")]
Task UpdatePetWithForm(
    long petId, 
    [AliasAs("name")][Query] string nAmE, 
    [AliasAs("status")][Query] string StAtUS);

in this example

var client = RestService.For<ISwaggerPetstoreOpenAPI30>("https://petstore3.swagger.io/api/v3");

var pet = await client.GetPetById(1);

Console.WriteLine($"Name: {pet.Name}");

await client.UpdatePetWithForm(
    petId: pet.Id,
    nAmE: $"{pet.Name} Updated",
    StAtUS: Status.Available.ToString());

pet = await client.GetPetById(1);

Console.WriteLine($"New Name: {pet.Name}");

outputs:

Name: Velociraptor
New Name: Velociraptor Updated

I suggest that we keep the "code friendly" camelCase style parameter naming and use [AliasAs()] to specify what the spec says the parameter should be called.

What do you think @guillaumeserale ?

from refitter.

guillaumeserale avatar guillaumeserale commented on July 21, 2024 1

@christianhelle yes, I agree; using [AliasAs()] seems the proper way to do it. I suggest it should be added only if the parameter name name and spec name nAmE differ.

from refitter.

christianhelle avatar christianhelle commented on July 21, 2024 1

Apparently the code was already there, I just had to make sure it respected the original casing

from refitter.

christianhelle avatar christianhelle commented on July 21, 2024

@guillaumeserale thanks for reporting this! I'll look into this tonight

from refitter.

christianhelle avatar christianhelle commented on July 21, 2024

@guillaumeserale my thoughts exactly. No need to use [AliasAs()] if the parameter name the same

from refitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.