When creating or editing an endpoint, if a required field has no value set, but it does have a default value, set the default value as the actual value.
@@ -253,7 +253,7 @@ class EndpointsPage extends React.Component<{}, State> {
if ((filterItem !== 'all' && (endpoint.type !== filterItem)) ||
(endpoint.name.toLowerCase().indexOf(filterText || '') === -1 &&
// $FlowIssue
- endpoint.description.toLowerCase().indexOf(filterText) === -1)
+ (!endpoint.description || endpoint.description.toLowerCase().indexOf(filterText) === -1))
) {
return false
}
@@ -83,6 +83,12 @@ export const fieldsToPayload = (data: { [string]: mixed }, schema: SchemaPropert
Object.keys(schema.properties).forEach(fieldName => {
if (data[fieldName] && typeof data[fieldName] !== 'object') {
info[fieldName] = data[fieldName]
+ } else if (
+ !data[fieldName] &&
+ schema.required && schema.required.find(f => f === fieldName) &&
+ schema.properties[fieldName].default
+ ) {
+ info[fieldName] = schema.properties[fieldName].default
})