swagger-api / swagger-api/swagger-ui
maxProperties specified in schema doesn't limit the amount of properties being sent in try it out
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: macOS
- Browser: chrome
- Version: 122.0.6261.69
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: Test API
version: 1.0.0
paths:
/users:
post:
summary: Create a user
description: Create a user, one of various ways
requestBody:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/UserSource'
responses:
'204':
description: Successfully opened document
'400':
description: Invalid request
content:
application/json:
schema:
properties:
output:
type: string
example: "Invalid request"
components:
schemas:
UserSource:
type: object
properties:
name:
description: Full name
type: string
example: "John Smith"
badgeid:
description: Badge number
type: integer
format: uint32
example: 959310
email:
description: E-mail
type: string
example: "jsmith@business.com"
minProperties: 1
maxProperties: 1
Describe the bug you're encountering
maxProperties parameter in schema is not validated in Swagger UI. It allows to send more properties than the set limit.
To reproduce...
Steps to reproduce the behavior:
- Load the example definition
- Expand POST
/users - Click on try it out
- See each parameter filled with default value
- Click on execute
- See that request was sent, despite
maxPropertiesbeing set to 1
Expected behavior
Swagger UI should validate that we have specified more properties than the max limit, and show an error based on that.
Screenshots
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
Start by loading the supplied OpenAPI 3.0 definition in Swagger UI and reproducing the Try it Out flow for POST /users. Trace how the form handles maxProperties for the UserSource schema; done means submitting more properties than the limit is blocked and an appropriate validation error is shown.
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
- 48/100