Open
Description
Q&A (please complete the following information)
- OS: Windows 10
- Browser: Chrome, Firefox latest
- Method of installation: petstore.swagger.io, editor.swagger.io
- Swagger-UI version: 4.2.1
- Swagger/OpenAPI version: OpenAPI 2.0
Content & configuration
Example Swagger/OpenAPI definition:
swagger: '2.0'
info:
title: test
version: 1.0.0
host: httpbin.org
schemes:
- https
paths:
/post:
post:
consumes:
- application/json
parameters:
- in: body
name: body
required: true
schema:
$ref: '#/definitions/MyModel'
responses:
'200':
description: ok
definitions:
MyModel:
type: object
required:
- prop1
properties:
prop1:
type: string
example: foo
minLength: 10
prop2:
type: string
pattern: ^\d+$
Describe the bug you're encountering
If a JSON request body does not validate against its schema (e.g. a required property is missing, or some property value does not match minLength
or pattern
), the "Execute" button does not work, it does nothing. Also, there are no errors at all on the page or in the browser console, which makes it very hard to troubleshoot the issue.
Given an equivalent OpenAPI 3 spec, "Execute" button works fine. (It looks like OAS3 request bodies are not validated.)
To reproduce...
- Paste the spec above into https://editor.swagger.io
- Expand the operation, click "Try it out" and then "Execute".
Expected result: the request is sent.
Actual result: Nothing happens.
- Replace the body with the following, and click "Execute" again.
{
"prop1": "testtesttest",
"prop2": "1"
}
This time "Execute" works and the request is sent.
- Now replace the body with the following and click "Execute" again:
{
"prop2: "1"
}
Expected result: the request is sent.
Actual result: Nothing happens.