Можно ли в моей спецификации OpenAPI определить параметр как объект без необходимости определять его свойства (анонимный объект)? В частности, я хочу, чтобы мой API мог принимать массив этих анонимных объектов.
Вот что у меня есть, но я получаю сообщение об ошибке «недопустимое определение параметра» в редакторе Swagger.
swagger: '2.0'
info:
title: Test API
description: Test
version: "1.0.0"
host: api.example.com
schemes:
- https
basePath: /v1
produces:
- application/json
paths:
/api/example:
post:
description: Endpoint description
parameters:
- name: param1
in: query
description: param1
required: true
type: array
items:
type: object
- name: param2
in: query
description: param2
required: true
type: string
responses:
200:
description: error response
schema:
type: object
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
definitions:
Error:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
fields:
type: string
Вот ошибка:
Object
code: "ONE_OF_MISSING"
params: Array [0]
message: "Not a valid parameter definition"
path: Array [5]
schemaId: "http://swagger.io/v2/schema.json#"
inner: Array [2]
0: Object
code: "ONE_OF_MISSING"
params: Array [0]
message: "Data does not match any schemas from 'oneOf'"
path: Array [5]
inner: Array [2]
1: Object
code: "OBJECT_MISSING_REQUIRED_PROPERTY"
params: Array [1]
0: "$ref"
message: "Missing required property: $ref"
path: Array [5]
0: "paths"
1: "/api/example"
2: "post"
3: "parameters"
4: "0"
level: 900
type: "Swagger Error"
description: "Not a valid parameter definition"
lineNumber: 23