restful-react
restful-react copied to clipboard
Object key invalid after code gen
Describe the bug I got a invalid key name after I use code gen function if some symbols exits in the swagger.
To Reproduce Steps to reproduce the behavior:
- add a line of "- name: X-USERNAME" to the swagger file
- restful-react import
@DavidSun0403 thanks for the issue! Would you mind providing a swagger document we can test against?
/model:
get:
tags:
- model
summary: get all model
operationId: getAllModel
description: |
It is avaible for listing choosen model by giving query parameters.
parameters:
- name: page
in: query
description: page number
required: false
schema:
type: integer
- name: size
in: query
description: size number of per page
required: false
schema:
type: integer
- name: sort
in: query
description: sort and order field
required: false
schema:
type: string
example: id,asc
- name: state
in: query
description: filter field
required: false
schema:
type: string
enum: [training, setup, setting, abort]
example: setup
- name: name
in: query
description: filter field
required: false
schema:
type: string
example: vs_ad
- name: version
in: query
description: |
filter field \
if value of `current`, it indicates the `isCurrent` is true and return the current models.
required: false
example: current
schema:
type: string
- name: title[regex]
in: query
description: search field
required: false
schema:
type: string
responses:
"200":
description: get all results
content:
application/json:
schema:
$ref: "#/components/schemas/ArrayofModel"
"400":
description: bad request
Here is one of our api, the problem is when the parameter name contains some symbol(as this case, title[regex]), the code gen function will just set title[regex] as a json key which is invalid. I have to add quotation mark manually.
@DavidSun0403 Interesting, I never saw API with brakets the query params as title[regex]
, how do you use this in real life?
curl http://myapi.com/model?title[regex]=testÂ
or are you actually expect a real regex? 🤔
We can probably just use escape the key to avoid this kind of strange API 😬