Skip to content

Misleading documentation regarding path variable mapping #8

@sholmp

Description

@sholmp

https://oatpp.io/docs/components/api-controller/#path-variables-mapping
The following does not compile

ENDPOINT("GET", "/users/{userId}", getUserById,
         PATH(Int64, userId)) 
{
  OATPP_LOGD("Test", "userId=%d", userId->getValue());
  return createResponse(Status::CODE_200, "OK");
}

Produces error:
error: request for member ‘getValue’ in ‘*(& userId)->oatpp::data::mapping::type::Primitive<long int, oatpp::data::mapping::type::__class::Int64>::<anonymous>.oatpp::data::mapping::type::ObjectWrapper<long int, oatpp::data::mapping::type::__class::Int64>::operator->()’, which is of non-class type ‘long int’ 61 | OATPP_LOGD("Test", "userId=%d", userId->getValue());

If the userId pointer is dereferenced it works

ENDPOINT("GET", "/users/{userId}", 
PATH(Int64, userId)) 
{
    OATPP_LOGD("Test", "userId=%d", *userId);
    return createResponse(Status::CODE_200, "OK");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions