refactor: lint
This commit is contained in:
@@ -19,7 +19,9 @@ export const JavaOkhttpCodegen = {
|
||||
}) => {
|
||||
const requestString = []
|
||||
|
||||
requestString.push("OkHttpClient client = new OkHttpClient().newBuilder().build();")
|
||||
requestString.push(
|
||||
"OkHttpClient client = new OkHttpClient().newBuilder().build();"
|
||||
)
|
||||
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||
@@ -28,17 +30,21 @@ export const JavaOkhttpCodegen = {
|
||||
requestBody = `"${requestBody}"`
|
||||
} else requestBody = JSON.stringify(requestBody)
|
||||
|
||||
requestString.push(`MediaType mediaType = MediaType.parse("${contentType}");`)
|
||||
requestString.push(`RequestBody body = RequestBody.create(mediaType,${requestBody});`)
|
||||
requestString.push(
|
||||
`MediaType mediaType = MediaType.parse("${contentType}");`
|
||||
)
|
||||
requestString.push(
|
||||
`RequestBody body = RequestBody.create(mediaType,${requestBody});`
|
||||
)
|
||||
}
|
||||
|
||||
requestString.push("Request request = new Request.Builder()")
|
||||
requestString.push(`.url(\"${url}${pathName}${queryString}\")`)
|
||||
requestString.push(`.url("${url}${pathName}${queryString}")`)
|
||||
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
requestString.push(`.method(\"${method}\", body)`)
|
||||
requestString.push(`.method("${method}", body)`)
|
||||
} else {
|
||||
requestString.push(`.method(\"${method}\", null)`)
|
||||
requestString.push(`.method("${method}", null)`)
|
||||
}
|
||||
|
||||
if (auth === "Basic Auth") {
|
||||
@@ -49,12 +55,14 @@ export const JavaOkhttpCodegen = {
|
||||
)}") \n`
|
||||
)
|
||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||
requestString.push(`.addHeader("authorization", "Bearer ${bearerToken}" ) \n`)
|
||||
requestString.push(
|
||||
`.addHeader("authorization", "Bearer ${bearerToken}" ) \n`
|
||||
)
|
||||
}
|
||||
|
||||
if (headers) {
|
||||
headers.forEach(({ key, value }) => {
|
||||
if (key) requestString.push(`.addHeader(\"${key}\", \"${value}\")`)
|
||||
if (key) requestString.push(`.addHeader("${key}", "${value}")`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user