swagger-api / swagger-api/swagger-ui

maxProperties specified in schema doesn't limit the amount of properties being sent in try it out

Open
#9,675 1 comment 0 reactions 0 assignees View on GitHub

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:

  1. Load the example definition
  2. Expand POST /users
  3. Click on try it out
  4. See each parameter filled with default value
  5. Click on execute
  6. See that request was sent, despite maxProperties being 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
Screenshot 2024-03-08 at 10 27 22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.