Lint, ES6, popover for codegen
This commit is contained in:
@@ -1,34 +1,33 @@
|
|||||||
import feeds from "../feeds"
|
import feeds from "../feeds"
|
||||||
import { shallowMount } from "@vue/test-utils"
|
import { shallowMount } from "@vue/test-utils"
|
||||||
|
|
||||||
jest.mock("~/helpers/fb", () => {
|
jest.mock("~/helpers/fb", () => ({
|
||||||
return {
|
__esModule: true,
|
||||||
__esModule: true,
|
|
||||||
fb: {
|
|
||||||
currentFeeds: [
|
|
||||||
{
|
|
||||||
id: "test1",
|
|
||||||
label: "First",
|
|
||||||
message: "First Message",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "test2",
|
|
||||||
label: "Second",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "test3",
|
|
||||||
message: "Third Message",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "test4",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
deleteFeed: jest.fn(() => Promise.resolve()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { fb } = require("~/helpers/fb")
|
fb: {
|
||||||
|
currentFeeds: [
|
||||||
|
{
|
||||||
|
id: "test1",
|
||||||
|
label: "First",
|
||||||
|
message: "First Message",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "test2",
|
||||||
|
label: "Second",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "test3",
|
||||||
|
message: "Third Message",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "test4",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
deleteFeed: jest.fn(() => Promise.resolve()),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
import { fb } from "~/helpers/fb"
|
||||||
|
|
||||||
const factory = () =>
|
const factory = () =>
|
||||||
shallowMount(feeds, {
|
shallowMount(feeds, {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import inputform from "../inputform"
|
import inputform from "../inputform"
|
||||||
import { shallowMount } from "@vue/test-utils"
|
import { shallowMount } from "@vue/test-utils"
|
||||||
|
|
||||||
jest.mock("~/helpers/fb", () => {
|
jest.mock("~/helpers/fb", () => ({
|
||||||
return {
|
__esModule: true,
|
||||||
__esModule: true,
|
|
||||||
fb: {
|
|
||||||
writeFeeds: jest.fn(() => Promise.resolve()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { fb } = require("~/helpers/fb")
|
fb: {
|
||||||
|
writeFeeds: jest.fn(() => Promise.resolve()),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
import { fb } from "~/helpers/fb"
|
||||||
|
|
||||||
const factory = () =>
|
const factory = () =>
|
||||||
shallowMount(inputform, {
|
shallowMount(inputform, {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import logout from "../logout"
|
import logout from "../logout"
|
||||||
import { shallowMount, createLocalVue } from "@vue/test-utils"
|
import { shallowMount, createLocalVue } from "@vue/test-utils"
|
||||||
|
|
||||||
jest.mock("~/helpers/fb", () => {
|
jest.mock("~/helpers/fb", () => ({
|
||||||
return {
|
__esModule: true,
|
||||||
__esModule: true,
|
|
||||||
fb: {
|
|
||||||
signOutUser: jest.fn(() => Promise.resolve()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { fb } = require("~/helpers/fb")
|
fb: {
|
||||||
|
signOutUser: jest.fn(() => Promise.resolve()),
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
import { fb } from "~/helpers/fb"
|
||||||
|
|
||||||
const $toast = {
|
const $toast = {
|
||||||
info: jest.fn(),
|
info: jest.fn(),
|
||||||
|
|||||||
@@ -22,39 +22,43 @@ export const CsRestSharpCodegen = {
|
|||||||
|
|
||||||
// initial request setup
|
// initial request setup
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
requestBody = requestBody.replace(/"/g,'""'); // escape quotes for C# verbatim string compatibility
|
requestBody = requestBody.replace(/"/g, '""') // escape quotes for C# verbatim string compatibility
|
||||||
|
|
||||||
// prepare data
|
// prepare data
|
||||||
let requestDataFormat;
|
let requestDataFormat
|
||||||
let requestContentType;
|
let requestContentType
|
||||||
|
|
||||||
if(isJSONContentType(contentType)) {
|
if (isJSONContentType(contentType)) {
|
||||||
requestDataFormat = 'DataFormat.Json'
|
requestDataFormat = "DataFormat.Json"
|
||||||
requestContentType = 'text/json'
|
requestContentType = "text/json"
|
||||||
} else {
|
} else {
|
||||||
requestDataFormat = 'DataFormat.Xml'
|
requestDataFormat = "DataFormat.Xml"
|
||||||
requestContentType = 'text/xml'
|
requestContentType = "text/xml"
|
||||||
}
|
}
|
||||||
|
|
||||||
const verbs = [
|
const verbs = [
|
||||||
{ verb: 'GET', csMethod: 'Get' },
|
{ verb: "GET", csMethod: "Get" },
|
||||||
{ verb: 'POST', csMethod: 'Post' },
|
{ verb: "POST", csMethod: "Post" },
|
||||||
{ verb: 'PUT', csMethod: 'Put' },
|
{ verb: "PUT", csMethod: "Put" },
|
||||||
{ verb: 'PATCH', csMethod: 'Patch' },
|
{ verb: "PATCH", csMethod: "Patch" },
|
||||||
{ verb: 'DELETE', csMethod: 'Delete' },
|
{ verb: "DELETE", csMethod: "Delete" },
|
||||||
]
|
]
|
||||||
|
|
||||||
// create client and request
|
// create client and request
|
||||||
requestString.push(`var client = new RestClient("${url}");\n\n`)
|
requestString.push(`var client = new RestClient("${url}");\n\n`)
|
||||||
requestString.push(`var request = new RestRequest("${pathName}${queryString}", ${requestDataFormat});\n\n`)
|
requestString.push(
|
||||||
|
`var request = new RestRequest("${pathName}${queryString}", ${requestDataFormat});\n\n`
|
||||||
|
)
|
||||||
|
|
||||||
// authentification
|
// authentification
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
requestString.push(`client.Authenticator = new HttpBasicAuthenticator("${httpUser}", "${httpPassword}");\n`)
|
requestString.push(
|
||||||
|
`client.Authenticator = new HttpBasicAuthenticator("${httpUser}", "${httpPassword}");\n`
|
||||||
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`request.AddHeader("Authorization", "Bearer ${bearerToken}");\n`)
|
requestString.push(`request.AddHeader("Authorization", "Bearer ${bearerToken}");\n`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
requestString.push(`request.AddHeader("Content-Type", "${contentType}");\n`)
|
requestString.push(`request.AddHeader("Content-Type", "${contentType}");\n`)
|
||||||
@@ -70,19 +74,23 @@ export const CsRestSharpCodegen = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestString.push(`\n`)
|
requestString.push(`\n`)
|
||||||
|
|
||||||
// set body
|
// set body
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
requestString.push(`request.AddParameter("${requestContentType}", @"${requestBody}", ParameterType.RequestBody);\n\n`)
|
requestString.push(
|
||||||
|
`request.AddParameter("${requestContentType}", @"${requestBody}", ParameterType.RequestBody);\n\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// process
|
// process
|
||||||
const verb = verbs.find(v => v.verb === method)
|
const verb = verbs.find((v) => v.verb === method)
|
||||||
requestString.push(`var response = client.${verb.csMethod}(request);\n\n`)
|
requestString.push(`var response = client.${verb.csMethod}(request);\n\n`)
|
||||||
|
|
||||||
// analyse result
|
// analyse result
|
||||||
requestString.push(`if (!response.IsSuccessful)\n{\n Console.WriteLine("An error occured " + response.ErrorMessage);\n}\n\n`)
|
requestString.push(
|
||||||
|
`if (!response.IsSuccessful)\n{\n Console.WriteLine("An error occured " + response.ErrorMessage);\n}\n\n`
|
||||||
|
)
|
||||||
|
|
||||||
requestString.push(`var result = response.Content;\n`)
|
requestString.push(`var result = response.Content;\n`)
|
||||||
|
|
||||||
return requestString.join("")
|
return requestString.join("")
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const NodeJsRequestCodegen = {
|
|||||||
reqBodyType = "body"
|
reqBodyType = "body"
|
||||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||||
const formData = []
|
const formData = []
|
||||||
if (requestBody.indexOf("=") > -1) {
|
if (requestBody.includes("=")) {
|
||||||
requestBody.split("&").forEach((rq) => {
|
requestBody.split("&").forEach((rq) => {
|
||||||
const [key, val] = rq.split("=")
|
const [key, val] = rq.split("=")
|
||||||
formData.push(`"${key}": "${val}"`)
|
formData.push(`"${key}": "${val}"`)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export const PhpCurlCodegen = {
|
|||||||
} else if (isJSONContentType(contentType)) {
|
} else if (isJSONContentType(contentType)) {
|
||||||
requestBody = JSON.stringify(requestBody)
|
requestBody = JSON.stringify(requestBody)
|
||||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||||
if (requestBody.indexOf("=") > -1) {
|
if (requestBody.includes("=")) {
|
||||||
requestBody = `"${requestBody}"`
|
requestBody = `"${requestBody}"`
|
||||||
} else {
|
} else {
|
||||||
const requestObject = JSON.parse(requestBody)
|
const requestObject = JSON.parse(requestBody)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const PowerShellRestMethod = {
|
|||||||
}) => {
|
}) => {
|
||||||
const methodsWithBody = ["Put", "Post", "Delete"]
|
const methodsWithBody = ["Put", "Post", "Delete"]
|
||||||
const formattedMethod = method[0].toUpperCase() + method.substring(1).toLowerCase()
|
const formattedMethod = method[0].toUpperCase() + method.substring(1).toLowerCase()
|
||||||
const includeBody = methodsWithBody.indexOf(formattedMethod) >= 0
|
const includeBody = methodsWithBody.includes(formattedMethod)
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
let genHeaders = []
|
||||||
let variables = ""
|
let variables = ""
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export const PythonHttpClientCodegen = {
|
|||||||
requestString.push(`payload = ${requestBody}\n`)
|
requestString.push(`payload = ${requestBody}\n`)
|
||||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||||
const formData = []
|
const formData = []
|
||||||
if (requestBody.indexOf("=") > -1) {
|
if (requestBody.includes("=")) {
|
||||||
requestBody.split("&").forEach((rq) => {
|
requestBody.split("&").forEach((rq) => {
|
||||||
const [key, val] = rq.split("=")
|
const [key, val] = rq.split("=")
|
||||||
formData.push(`('${key}', '${val}')`)
|
formData.push(`('${key}', '${val}')`)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const PythonRequestsCodegen = {
|
|||||||
requestString.push(`data = ${requestBody}\n`)
|
requestString.push(`data = ${requestBody}\n`)
|
||||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||||
const formData = []
|
const formData = []
|
||||||
if (requestBody.indexOf("=") > -1) {
|
if (requestBody.includes("=")) {
|
||||||
requestBody.split("&").forEach((rq) => {
|
requestBody.split("&").forEach((rq) => {
|
||||||
const [key, val] = rq.split("=")
|
const [key, val] = rq.split("=")
|
||||||
formData.push(`('${key}', '${val}')`)
|
formData.push(`('${key}', '${val}')`)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const ShellHTTPie = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const methodsWithBody = ["POST", "PUT", "PATCH", "DELETE"]
|
const methodsWithBody = ["POST", "PUT", "PATCH", "DELETE"]
|
||||||
const includeBody = methodsWithBody.indexOf(method) >= 0
|
const includeBody = methodsWithBody.includes(method)
|
||||||
const requestString = []
|
const requestString = []
|
||||||
|
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ export class FirebaseInstance {
|
|||||||
author: this.currentUser.uid,
|
author: this.currentUser.uid,
|
||||||
author_name: this.currentUser.displayName,
|
author_name: this.currentUser.displayName,
|
||||||
author_image: this.currentUser.photoURL,
|
author_image: this.currentUser.photoURL,
|
||||||
team: team,
|
team,
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1043,11 +1043,23 @@
|
|||||||
<li>
|
<li>
|
||||||
<label for="requestType">{{ $t("request_type") }}</label>
|
<label for="requestType">{{ $t("request_type") }}</label>
|
||||||
<span class="select-wrapper">
|
<span class="select-wrapper">
|
||||||
<select id="requestType" v-model="requestType">
|
<v-popover>
|
||||||
<option v-for="gen in codegens" :key="gen.id" :value="gen.id">
|
<input
|
||||||
{{ gen.name }}
|
id="requestType"
|
||||||
</option>
|
v-model="requestType"
|
||||||
</select>
|
:placeholder="$t('choose_language')"
|
||||||
|
class="cursor-pointer"
|
||||||
|
readonly
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
|
<template slot="popover">
|
||||||
|
<div v-for="gen in codegens" :key="gen.id">
|
||||||
|
<button class="icon" @click="requestType = gen.id" v-close-popover>
|
||||||
|
{{ gen.name }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-popover>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user