I want to perform request validation with OpenAPI 3.0.x with style: simple
and path variables as Object.
As per the OAS specification document, I want to have below configuration in my API for path variables.
https://swagger.io/docs/specification/serialization/
style | Object id = {“role”: “admin”, “firstName”: “Alex”} |
---|---|
simple | /users/role,admin,firstName,Alex |
my backend apis should be as below:
http://test-api/users/role,admin,firstName,Alex
can anyone please suggest, how to create yml file for this configuration?
Thanks
i tried a couple of workaround but its not working and giving me json parsing error
openapi: 3.0.3
info:
title: My API
version: 1.0.0
paths:
/users/{id}:
get:
summary: my api endpoint
operationId: getUsersById
parameters:
- $ref: "#/components/parameters/path_id"
responses:
'200':
description: OK
content:
application/json:
schema: {}
'400':
description: Bad Request
content:
'application/problem+json':
schema:
$ref: "#/components/schemas/problem_json"
components:
parameters:
path_id:
name: id
in: path
style: simple
explode: false
schema:
type: object
properties:
role:
enum:
- admin
- user
firstName:
type: string
schemas:
problem_json:
title: RFC9457 - Problem JSON
description: Problem Details for HTTP APIs - RFC9457
type: object
properties:
type:
type: string
format: 'uri-reference'
status:
type: number
title:
type: string
detail:
type: string
instance:
type: string
format: 'uri-reference'