mirror of https://gitee.com/bigwinds/arangodb
Foxx: No more nickname method – is set automatically
Happy hacking, @fceller, @mchacki and @jsteemann 😉
This commit is contained in:
parent
84a311fac6
commit
8ec4887973
|
@ -197,9 +197,6 @@ properties of the request.
|
|||
#### Describing a queryParam
|
||||
@copydetails JSF_foxx_RequestContext_queryParam
|
||||
|
||||
#### Documenting the nickname of a route
|
||||
@copydetails JSF_foxx_RequestContext_nickname
|
||||
|
||||
#### Documenting the summary of a route
|
||||
@copydetails JSF_foxx_RequestContext_summary
|
||||
|
||||
|
|
|
@ -308,28 +308,14 @@ function DocumentationAndConstraintsSpec () {
|
|||
testDefineMetaData: function () {
|
||||
app.get('/foxx', function () {
|
||||
//nothing
|
||||
}).nickname("a").summary("b").notes("c");
|
||||
}).summary("b").notes("c");
|
||||
|
||||
assertEqual(routes.length, 1);
|
||||
assertEqual(routes[0].docs.nickname, "a");
|
||||
assertEqual(routes[0].docs.nickname, "get_foxx");
|
||||
assertEqual(routes[0].docs.summary, "b");
|
||||
assertEqual(routes[0].docs.notes, "c");
|
||||
},
|
||||
|
||||
testNicknameFormat: function () {
|
||||
var error;
|
||||
|
||||
try {
|
||||
app.get('/foxx', function () {
|
||||
//nothing
|
||||
}).nickname("a b");
|
||||
} catch(e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
assertEqual(error.substr(0,31), "Nickname may only contain [a-z]".substr(0,31));
|
||||
},
|
||||
|
||||
testSummaryRestrictedTo60Characters: function () {
|
||||
var error;
|
||||
|
||||
|
|
|
@ -479,6 +479,14 @@ _.extend(Application.prototype, {
|
|||
}
|
||||
});
|
||||
|
||||
internal.constructNickname = function (httpMethod, url) {
|
||||
'use strict';
|
||||
return (httpMethod + "_" + url)
|
||||
.replace(/\W/g, '_')
|
||||
.replace(/((_){2,})/g, '_')
|
||||
.toLowerCase();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_RequestContext_initializer
|
||||
/// @brief Context of a Request Definition
|
||||
|
@ -493,6 +501,7 @@ RequestContext = function (route) {
|
|||
"int": "/[0-9]+/",
|
||||
"string": "/.+/"
|
||||
};
|
||||
this.route.docs.nickname = internal.constructNickname(route.docs.httpMethod, route.url.match);
|
||||
};
|
||||
|
||||
_.extend(RequestContext.prototype, {
|
||||
|
@ -586,20 +595,6 @@ _.extend(RequestContext.prototype, {
|
|||
return this;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_RequestContext_nickname
|
||||
/// Set the nickname for this route in the documentation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nickname: function (nickname) {
|
||||
'use strict';
|
||||
if (!nickname.match(/^[a-z]+$/)) {
|
||||
throw "Nickname may only contain [a-z], not '" + nickname + "'";
|
||||
}
|
||||
this.route.docs.nickname = nickname;
|
||||
return this;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @fn JSF_foxx_RequestContext_summary
|
||||
/// @brief Set the summary for this route in the documentation
|
||||
|
|
Loading…
Reference in New Issue