ring-swagger & compojure-api
minsunlee 2018-01-16T04:48:18.000136Z

hello, i have a question with using text/plain format.

minsunlee 2018-01-16T04:49:20.000273Z

i use

minsunlee 2018-01-16T04:49:22.000149Z

[muuntaja.core :as muuntaja] [ring.util.http-response :refer [ok]] [compojure.api.sweet :refer :all] [compojure.route :as route]

minsunlee 2018-01-16T04:50:14.000188Z

@minsunlee uploaded a file: https://clojurians.slack.com/files/U06919Z6H/F8TD884LD/-.txt

minsunlee 2018-01-16T04:50:47.000010Z

like that, but i can’t send request as text/plain format

minsunlee 2018-01-16T04:52:15.000045Z

with those code, request(as json) is okay

minsunlee 2018-01-16T04:52:32.000144Z

@minsunlee uploaded a file: https://clojurians.slack.com/files/U06919Z6H/F8SL2A40G/-.txt

minsunlee 2018-01-16T04:55:30.000032Z

if i sent text/plain, response is

minsunlee 2018-01-16T04:55:39.000161Z

@minsunlee uploaded a file: https://clojurians.slack.com/files/U06919Z6H/F8SP1SQQZ/-.clj

minsunlee 2018-01-16T04:58:21.000067Z

How can i send my request as text/plain format.

minsunlee 2018-01-16T04:59:42.000106Z

something wrong with creating format? or need some options?

minsunlee 2018-01-16T05:00:26.000140Z

@ikitommi 😉

ikitommi 2018-01-16T06:04:07.000208Z

@minsunlee hi, the :body-params sets a requirement for a body of map with keys`. To define Schema for the whole body, you can use :body [body String].

ikitommi 2018-01-16T06:05:06.000200Z

Still, your body seens nil, so the string doesn't get read. What kind of plain-text request are you sending?

minsunlee 2018-01-16T06:12:35.000162Z

if i use that :body [body String]

minsunlee 2018-01-16T06:12:53.000263Z

@minsunlee uploaded a file: https://clojurians.slack.com/files/U06919Z6H/F8SLK2JAU/-.clj

minsunlee 2018-01-16T06:13:43.000141Z

i just use simple string like ‘abcde’

minsunlee 2018-01-16T06:14:08.000069Z

is compojure-api always accept json body?

ikitommi 2018-01-16T06:29:36.000183Z

@minsunlee I believe curl sets the content-type header to application/x-www-form-urlencoded by default for POSTs. If you override that to text/plain it should work.

ikitommi 2018-01-16T06:29:51.000132Z

e.g. add -H "Content-Type: text/plain"