Skip to content

improper validation of x-www-form-urlencoded with arbitrary nested allOf #1045

@mikhailovavexmocom

Description

@mikhailovavexmocom

in case of json, there're ways to describe and validate complex structures;
with form-data the same can be achieved - however, currently there's need of properties duplication;
give kin dry spec - it fails

example:

openapi: 3.0.3
info:
  version: 1.0.0
  title: sample api
  description: api service paths to test the issue
paths:
  /api/path:
    post:
      summary: path
      tags:
        - api
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/PathRequest' }
          application/x-www-form-urlencoded:
            schema: { $ref: '#/components/schemas/PathRequest' }
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema: { $ref: '#/components/schemas/PathResponse' }
components:
  schemas:
    Msg_Opt:
      properties:
        msg: { type: string }
    Msg:
      allOf:
        - $ref: '#/components/schemas/Msg_Opt'
        - required: [ msg ]
    Name:
      properties:
        name: { type: string }
      required: [ name ]
    Id:
      properties:
        id:
          type: string
          format: uint64
      required: [ id ]
    PathRequest:
      type: object
      allOf:
        - $ref: '#/components/schemas/Msg'
        - $ref: '#/components/schemas/Name'
    PathResponse:
      type: object
      allOf:
        - $ref: '#/components/schemas/PathRequest'
        - $ref: '#/components/schemas/Id'

which fails on msg=message&name=some+name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions