I am adding the field 'accountType' to our yaml files, with the same setup as an existing field 'status', but getting an error when calling a GET /accounts endpoint in Postman with status and accountType as filters.
From yaml:
paths:
/accounts:
get:
operationId: getAccounts
summary: Retrieve a list of accounts
tags:
- accounts
parameters:
- $ref: '#/components/parameters/accountName'
- $ref: '#/components/parameters/status'
- $ref: '#/components/parameters/accountType'
responses:
'200':
$ref: '#/components/responses/Accounts'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthenticated'
'500':
$ref: '#/components/responses/InternalServerError'
components:
schemas:
Account:
type: object
properties:
accountId:
type: string
description: unique identifier for the accounts
readOnly: true
name:
type: string
description: unique user friendly display name for an account
minLength: 3
maxLength: 100
status:
type: string
description: status for an account
enum: ['Active', 'Disabled', 'Merged']
accountType:
type: string
description: specifies type of account within the company ecosystem.
enum: ['Owner', 'Partner', 'Maker', 'Buyer', 'Unknown']
ValidStatus:
type: array
items:
type: string
enum: ['Active', 'Disabled', 'Merged']
uniqueItems: true
ValidAccountType:
type: array
items:
type: string
enum: ['Owner', 'Partner', 'Maker', 'Buyer', 'Unknown']
uniqueItems: true
parameters:
status:
name: status
in: query
description: Filters account list with specified status
required: false
explode: false
schema:
$ref: '#/components/schemas/ValidStatus'
accountType:
name: accountType
in: query
description: Filters account list with specified type
required: false
explode: false
schema:
$ref: '#/components/schemas/ValidAccountType'
Query without accountType filter:
{{baseUrl}}/accounts?status=Active&fields=status,accountType
Results:
Status: 200 OK
Content:
{
count: 2,
items: [
{
accountId: 1,
name: 'test1'
status: 'Active'
accountType: 'Maker'
},
{
accountId: 3,
name: 'test3'
status: 'Active'
accountType: 'Owner'
}
]
}
Query with accountType filter:
{{baseUrl}}/accounts?status=Active&accountType=Maker&fields=status,accountType
Error:
{
"title": "BadRequestError",
"status": 400,
"detail": "Error while validating request: request.query.accountType should be array",
"type": "http://localhost:10080/api/v1/errorTypes/BadRequestError",
"_links": {
"type": {
"href": "http://localhost:10080/api/v1/errorTypes/BadRequestError"
}
}
}
Why is the validation complaining about accountType, when status is setup exactly the same but with no error?