Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REST] Default parameter taking precedence #1125

Closed
matthieukern opened this issue Jun 5, 2015 · 0 comments
Closed

[REST] Default parameter taking precedence #1125

matthieukern opened this issue Jun 5, 2015 · 0 comments

Comments

@matthieukern
Copy link

Hi! I have something that looks like a bug in the REST API generator. When I have this code :

//server
module app;

import vibe.d;

interface ILlama {
    @bodyParam("llama", "llama")
    string updateLlama(string llama = null);
}

class Llama : ILlama {
    string updateLlama(string llama) {
        logInfo("Llama: %s", llama);
        return llama;
    }
}

shared static this() {
    setLogLevel(LogLevel.debug_);

    auto settings = new HTTPServerSettings;
    settings.port = 8080;
    settings.bindAddresses = ["127.0.0.1"];

    auto router = new URLRouter;
    router.registerRestInterface(new Llama);

    listenHTTP(settings, router);
}


//client
module app;

import vibe.d;

interface ILlama {
    string updateLlama(string llama = null);
}

shared static this() {
    runTask({
        auto api = new RestInterfaceClient!ILlama("http://127.0.0.1:8080/");

        logInfo("Llama: %s", api.updateLlama("llama"));
    });
}

In the code above, the parameter's default value of updateLlama seems to take precedence on the PATCH request's parameter, so I get a null value instead of the desired one. When I remove the default parameter, the request works fine and the argument is correctly deserialized.

Geod24 added a commit to Geod24/vibe.d that referenced this issue Jun 10, 2015
Geod24 added a commit to Geod24/vibe.d that referenced this issue Jun 10, 2015
Geod24 added a commit to Geod24/vibe.d that referenced this issue Jun 10, 2015
Geod24 added a commit to Geod24/vibe.d that referenced this issue Jun 10, 2015
Geod24 added a commit to Geod24/vibe.d that referenced this issue Jun 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant