Skip to content

Commit

Permalink
Build the package
Browse files Browse the repository at this point in the history
  • Loading branch information
kjagiello committed Apr 5, 2019
1 parent 5694209 commit a220849
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dist/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ _swaggerClient.default.makeApisTagOperation = function (client) {
required: required.includes(key)
})));
}, {});
} else if (parameter.in === "data") {
parameters.data = parameters.data || {};
parameters.data[parameter.name] = parameter;
} else if (parameter.in === "query") {
parameters[parameter.name] = parameter;
}
Expand Down
27 changes: 26 additions & 1 deletion dist/forms/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fieldFromSchema = fieldFromSchema;
exports.fieldFromNestedSchema = fieldFromNestedSchema;
exports.fieldFromFlatSchema = fieldFromFlatSchema;
exports.fieldFromErrorResponse = fieldFromErrorResponse;

function normalizePath(path) {
return path.replace("]", "").replace("[", ".");
}

function fieldFromSchema(schema, field) {
if (Array.isArray(schema)) {
return fieldFromFlatSchema(schema, field);
}

return fieldFromNestedSchema(schema, field);
} // TODO: more verbose error messages
// Nested schema is typically used for content-type application/json


function fieldFromSchema(schema, field) {
function fieldFromNestedSchema(schema, field) {
var normalizedSchema = {
type: "object",
properties: schema
Expand All @@ -36,6 +47,20 @@ function fieldFromSchema(schema, field) {

throw new Error("Encountered lookup \"".concat(key, "\" on unsupported type \"").concat(acc.type, "\"."));
}, normalizedSchema);
} // Flat schema is typically used for content-type multipart/form-data


function fieldFromFlatSchema(schema, field) {
var value = schema.find(function (_ref) {
var name = _ref.name;
return name === field;
});

if (typeof value === "undefined") {
throw new Error("Encountered a non-existent field \"".concat(field, "\"."));
}

return value;
}

function fieldFromErrorResponse(response, field) {
Expand Down

0 comments on commit a220849

Please sign in to comment.