@valensh1 I am also stucked with that error.
Schema is the same and I have copied the Response and saved it as the Example so everything matches. But somewhere still shows expected “object”… Hope someone helps us
@valensh1 I am also stucked with that error.
Schema is the same and I have copied the Response and saved it as the Example so everything matches. But somewhere still shows expected “object”… Hope someone helps us
I have the same issue. It looks like any change I do into the YAML Definition is not being saved and synced with the request validation. Even if I remove completly the YAML Definition, same error “The response body needs to be of type object, but we found an array instead” is being returned when sending the request and doing the validation.
Am I missing something in the Postman UI?
I have the same issue
hi!
I have the same issue.
here is my YAML
for schema ‘Cosmos’ i have type ‘array’ and items with apropriate type (‘object’) and properties etc.
openapi: "3.0.0"
info:
version: 1.1.0
title: Cosmos
description: A sample API that retrieves constellations as an example to demonstrate features in the OpenAPI 3.0 specification
license:
name: MIT
servers:
- url: https://{{server}}.mock.pstmn.io
paths:
/cosmos:
get:
description: Returns all constellations in this sample dataset
summary: List all cosmos
operationId: listCosmos
tags:
- cosmos
responses:
"200":
description: An array of constellations
content:
application/json:
schema:
$ref: "#/components/schemas/Cosmos"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/cosmos/{cosmoId}:
get:
description: Returns a constellation based on a single ID
summary: Info for a specific constellation
operationId: showCosmoById
tags:
- cosmos
parameters:
- name: cosmoId
in: path
required: true
description: The id of the constellation to retrieve
schema:
type: string
responses:
"200":
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Cosmo"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Cosmos:
type: array
items:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Cosmo:
type: object
required:
- code
- message
properties:
id:
type: integer
format: int32
name:
type: string
tag:
type: string
description:
type: string
Error:
type: object
required:
- message
properties:
name:
type: string
message:
type: string
header:
type: string
and there is still the same error: expect object but get array.
Why is object expected - this is what I do not quite understand.
Guys!
It seems to be a bug somewhere in POSTMAN app.
It looks like the changes made in index.yaml and saved do not affect actually the workflow in POSTMAN. (You can test it by yourselves by changing some schemas and sending requests).
Solution for me (except that I have corrected all the needed fields in index.yaml) was - to restart the POSTMAN app.