swagger-api / swagger-api/swagger-ui
Inaccurate error message when an out-of-range integer value is entered for a parameter
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Ubuntu 20.04 LTS
- Browser: Chrome
- Version: 101.0.4951.64 (Official Build) (64-bit)
- Method of installation: Unsure, part of Python/Django/DRF/drf-spectacular?
- Swagger-UI version: 4.11.1?
- Swagger/OpenAPI version: OpenAPI 3.0.3
Content & configuration
You can simply use Swagger Editor (https://editor.swagger.io/), use the following YAML, then just try entering 0 or 11 for int_parameter via the "Try it out" feature then check the inaccurate error message.
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: Test API
version: 1.0.0
paths:
/test_endpoint/:
get:
parameters:
- in: query
name: int_parameter
schema:
type: integer
minimum: 1
maximum: 10
responses:
'200':
description: Success response
Swagger-UI configuration options:
Not sure, but you can simply use https://editor.swagger.io/ to reproduce the error.
Describe the bug you're encountering
The error message shown for entering an integer that is above the maximum or below the minimum is in accurate. Instead of stating, "Value must be greater than or equal to 1", it states "Value must be greater than 1". Instead of stating "Value must be less than or equal to 10", it states "Value must be less than 10".
Note, however, that the actual validation, that is, checking that the value is within 1 to 10 inclusive is done correctly. The problem is just with the error message shown when you enter a value out of range.
To reproduce...
Steps to reproduce the behavior:
- Enter the provided YAML into https://editor.swagger.io/
- Click on
/test_endpoint/to expand it - Click "Try it out"
- Enter the value 0 or 11 into
int_parametertextbox - Click "Execute"
- Hover over the red-filled
int_parametertextbox to see the error message. You'll see "Value must be greater than 1" if 0 was entered, and "Value must be less than 10" if 11 was entered.
Expected behavior
The error message should state "Value must be greater than or equal to 1" if 0 was entered, and state "Value must be less than or equal to 10" if 11 was entered.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Swagger Editor using the YAML definition and the Try it out flow, then trace the parameter validation message for values below minimum and above maximum. Done means the messages say “greater than or equal to 1” and “less than or equal to 10” while inclusive validation remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100