kopia lustrzana https://github.com/c9/core
default source is now body, simplified thigns
rodzic
bb6cb22cdc
commit
3c5c9e55b0
|
@ -54,13 +54,11 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
param: function(def, name, source) {
|
param: function(def, name, source) {
|
||||||
var param = def;
|
var param = def;
|
||||||
source = source || 'url';
|
|
||||||
|
|
||||||
// Singe edge case for implicit param generation from the url pathparts,
|
// Singe edge case for implicit param generation from the url pathparts,
|
||||||
// where the pathpart is not defined in params definition.
|
// where the pathpart is not defined in params definition.
|
||||||
if (typeof def === 'string' && !name) {
|
if (typeof def === 'string' && !name) {
|
||||||
return {
|
return {
|
||||||
name: def,
|
|
||||||
source: 'url',
|
source: 'url',
|
||||||
optional: false,
|
optional: false,
|
||||||
type: BuiltinTypes.get('string'),
|
type: BuiltinTypes.get('string'),
|
||||||
|
@ -75,18 +73,15 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
param.optional = !!param.optional;
|
param.optional = !!param.optional;
|
||||||
param.source = param.source || source;
|
param.source = param.source || source || "body";
|
||||||
|
param.type = param.type || "string";
|
||||||
|
|
||||||
// allow regular expressions as types
|
// allow regular expressions as types
|
||||||
if (param.type instanceof RegExp)
|
if (param.type instanceof RegExp)
|
||||||
param.type = new RegExpType(param.type);
|
param.type = new RegExpType(param.type);
|
||||||
|
|
||||||
if (param.source == "body")
|
|
||||||
param.type = param.type || "json";
|
if ( !/^body|url|query$/.test(param.source)) {
|
||||||
|
|
||||||
param.type = param.type || "string";
|
|
||||||
|
|
||||||
if (!/^body|url|query$/.test(param.source)) {
|
|
||||||
throw new Error("parameter source muste be 'url', 'query' or 'body'");
|
throw new Error("parameter source muste be 'url', 'query' or 'body'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue