swagger-ui input text box for body parameters of type string is unusable
See original GitHub issueSpecs
- Swagger spec version 2.0
- Swagger-UI docker image swaggerapi/swagger-ui v3.0.5 . a228b9ff44b6
Problem
I have some older endpoints which accept newline delimited strings which I’m trying define in a swagger spec.
The spec looks like this:
post: {
tags: [
"NLP"
],
summary: "",
description: "NLP parse one or more sentences passed in the body of the request",
operationId: "postNLPParse",
consumes: [
"text/plain: charset=utf8"
],
produces: [
"application/json; charset=utf8"
],
parameters: [
{
name: "sentences",
in: "body",
description: "Newline delimited sentences",
required: true,
schema: {
type: "string"
},
}
],
responses: {
200: {
description: "Success",
schema: {
$ref: "#/definitions/nlpResponse"
}
}
}
}
Desired solution
Ideally, I would like to be able to edit the string sent as the body in the swagger-ui for testing and demonstration. However the input text box will not allow spaces or newlines and treats the input as if it should be a JSON object ( forces the first character to be a ‘{’ ).
Is there anything I can modify in the spec to get around this limitation?
Apologies if this has been addressed somewhere already, I’ve searched for it and can’t find it.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Swagger integer type cause an error Expected `string` for ...
I found the reason: there should be consumes field defined as text/plain . By default it is application/json . The full code: {...
Read more >Swagger PUT/POST body value issue
Swagger reports the call to this accepts a parameter of type Workflow . Perfect. Templating from this generates a DTO parameter based function:...
Read more >Describing Parameters - Swagger
Each parameter has name , value type (for primitive value parameters) or schema (for request body), and optional description . Here is an...
Read more >Minimal APIs quick reference - Microsoft Learn
Route values; Query string; Header; Body (as JSON); Services provided by dependency injection; Custom. Binding from form values is not natively ...
Read more >Designing REST API with Open API Specification (OAS) v2.0 ...
The UI opens up editable text area for body & text fields for other applicable parameters like header & query (not shown here...
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 Free
Top 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

I’ll update my swagger-ui to 3.0.14 and try it.
I see it now, thanks @davidmfrey 😄