I am using Form Data format for APIs. The thing is how I am going to make OpenAPI input being larger by using textarea?
Advertisement
Answer
i’ve hacked.
my way is when specific field name, change input(type=text) to textarea.
first,
you serve self-hosting javascript and css for docs.
https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs.
second,
you change javascript source code like this.
JavaScript
x
32
32
1
var is_textarea = false;
2
// when fieldname is info_body, change to textarea
3
if(i === "info_body") {
4
is_textarea = true;
5
}
6
return l && "file" === l ? D.a.createElement(d, {
7
type: "file",
8
className: o.length ? "invalid" : "",
9
title: o.length ? o : "",
10
onChange: this.onChange,
11
disabled: h
12
}) :( !is_textarea ? D.a.createElement(kr.a, {
13
type: c && "password" === c ? "password" : "text",
14
className: o.length ? "invalid" : "",
15
title: o.length ? o : "",
16
value: n,
17
minLength: 0,
18
debounceTimeout: 350,
19
placeholder: i,
20
onChange: this.onChange,
21
disabled: h
22
}) : (D.a.createElement("textarea",{
23
className: o.length ? "invalid" : "",
24
title: o.length ? o : "",
25
value: n,
26
minLength: 0,
27
debounceTimeout: 350,
28
placeholder: i,
29
onChange: this.onChange,
30
disabled: h
31
}))) // here!
32
you can hack css for more pretty but not need it for me. enjoy.