Skip to content

Commit f0e715b

Browse files
committed
[try] show validation errors and disallow calls with invalid form
1 parent b85acd0 commit f0e715b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

app/scripts/directives/tryoperation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ SwaggerEditor.controller('TryOperation', function ($scope, formdataFilter,
55

66
// configure SchemaForm directive
77
SchemaForm.options = {
8-
theme: 'bootstrap3'
8+
theme: 'bootstrap3',
9+
10+
/*jshint camelcase: false */
11+
show_errors: true
912
};
1013

1114
var specs = $scope.$parent.specs;

app/styles/components/try-operation.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
}
5050
}
5151

52+
.call[disabled] {
53+
cursor: not-allowed;
54+
}
55+
5256
>div {
5357
>h5 {
5458
font-size: 1.0em;

app/templates/try-operation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div ng-controller="TryOperation" class="try-container">
22
<div class="request">
3-
<form schema-form="requestSchema" ng-model="requestModel"></form>
3+
<form schema-form="requestSchema" ng-model="requestModel" name="requestFrom"></form>
44
<div class="raw-request raw">
55
<div class="line url">
66
{{operation.operationName | uppercase}}
@@ -25,7 +25,7 @@
2525
</p>
2626
</div>
2727
<button ng-click="makeCall()" class="{{$parent.operationName}} call"
28-
ng-disabled="xhrInProgress">
28+
ng-disabled="xhrInProgress || !requestFrom.$valid">
2929
<span ng-if="xhrInProgress">Sending...</span>
3030
<span ng-if="!xhrInProgress">Send Request</span>
3131
</button>

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"apply-diff": "~1.2.4",
2828
"async": "~0.9.2",
2929
"json-editor": "~0.7.15",
30-
"schema-form": "~0.0.1",
30+
"schema-form": "~0.1.0",
3131
"ng-file-upload": "~4.2.1"
3232
},
3333
"dependencies": {

0 commit comments

Comments
 (0)