body type string is not recognized
See original GitHub issueWhen expecting a body parameter of type string (not a json!) - an error is returned saying the body parameter is not a string even if it is. Bellow is a sample yaml code that shows it. The references are for the definitions of the id param and the returned values (not relevant here).
/users/{id}/role:
parameters:
- $ref: '#/components/parameters/idParam'
put:
tags:
- Users
description: Set user role
responses:
'204':
$ref: '#/components/responses/NoContentResponse'
default:
$ref: '#/components/responses/ErrorResponse'
requestBody:
content:
text/plain:
schema:
type: string
enum:
- user
- moderator
- admin
description: New role
required: true
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Angular 4/5 HttpClient: Argument of type string is not ...
Type 'string' is not assignable to type '"body"'. Here is my version of the code: login(credentials: Credentials): Observable<any> { const ...
Read more >String was not recognized as a valid DateTime. clientRequestId
Solved: Hi, I am very new to Power Automate and this is one of my first flows, it is getting stuck at the...
Read more >Strings - Manual - PHP
A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character...
Read more >Fixing common type problems - Dart
Fix: Specify the type explicitly ... The example can be fixed by explicitly defining the map's type to be <String, num> . var...
Read more >Resolve template validation or template format errors in ... - AWS
For "Unrecognized parameter type: XXXXXXXX" or "Invalid template parameter ... For "Every Condition member must be a string" errors, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks! That was the problem 😃 In the code I added: app.use(express.json()); app.use(express.text());
Not sure there is anything you can do in the validator in this case. Maybe extend the error message after saying it should be a string, add the type you got - in my case i believe it was undefined (it was not a json and there was no parser for text so req.body left undefined) maybe adding the typeof req.body to the error message info will help. But I’m not so sure about this.