-
Notifications
You must be signed in to change notification settings - Fork 311
Open
Description
An error occurs when a parameter schema contains a const
value that is not a string, as shown below:
openapi: 3.1.0
info:
title: Example API
version: 1.0.0
paths:
/hello-world:
post:
tags:
- Example
parameters:
- name: Protocol-Version
in: header
required: true
schema:
$ref: '#/components/schemas/protocol-version'
components:
schemas:
protocol-version:
type: number
const: 1
The following error occurs:
Uncaught (in promise) TypeError: o.allowedValues.split is not a function
at de.inputParametersTemplate (api-request.js:520:1)
at api-request.js:217:1
at xR.render (callback-template.js:74:1)
at xR.update (callback-template.js:74:1)
at xR._$AS (common-utils.js:13:1)
at re (rapidoc-min.js:2:9848)
at ne._$AI (rapidoc-min.js:2:10938)
at se.p (rapidoc-min.js:2:10532)
at ne.$ (rapidoc-min.js:2:11583)
at ne._$AI (rapidoc-min.js:2:11079)
Since const
can accept any data type, it is necessary to handle non-string types appropriately.
Specifically, when assigning schema.const
to allowedValues
, it should be processed in advance using getPrintableVal()
:
RapiDoc/src/utils/schema-utils.js
Lines 79 to 84 in 7f53d25
// Set Allowed Values | |
info.allowedValues = schema.const | |
? schema.const | |
: Array.isArray(schema.enum) | |
? schema.enum.map((v) => (getPrintableVal(v))).join('┃') | |
: ''; |
RapiDoc/src/utils/schema-utils.js
Lines 92 to 95 in 7f53d25
info.allowedValues = schema.items.const | |
? schema.const | |
: Array.isArray(schema.items?.enum) | |
? schema.items.enum.map((v) => (getPrintableVal(v))).join('┃') |
Metadata
Metadata
Assignees
Labels
No labels