mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-22 12:15:38 +00:00
chore: fix lang constructs
This commit is contained in:
@@ -29,7 +29,7 @@ const { safeParseJson, outdentString } = require('./utils');
|
||||
*
|
||||
*/
|
||||
const grammar = ohm.grammar(`Bru {
|
||||
BruFile = (meta | http | grpc | query | params | headers | metadata | auths | bodies | varsandassert | script | tests | settings | docs)*
|
||||
BruFile = (meta | http | grpc | ws | query | params | headers | metadata | auths | bodies | varsandassert | script | tests | settings | docs)*
|
||||
auths = authawsv4 | authbasic | authbearer | authdigest | authNTLM | authOAuth2 | authwsse | authapikey | authOauth2Configs
|
||||
bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body | bodygrpc
|
||||
bodyforms = bodyformurlencoded | bodymultipart | bodyfile
|
||||
@@ -88,6 +88,7 @@ const grammar = ohm.grammar(`Bru {
|
||||
|
||||
http = get | post | put | delete | patch | options | head | connect | trace | httpcustom
|
||||
grpc = "grpc" dictionary
|
||||
ws = "ws" dictionary
|
||||
get = "get" dictionary
|
||||
post = "post" dictionary
|
||||
put = "put" dictionary
|
||||
@@ -420,6 +421,11 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
||||
grpc: mapPairListToKeyValPair(dictionary.ast)
|
||||
};
|
||||
},
|
||||
ws(_1, dictionary) {
|
||||
return {
|
||||
ws: mapPairListToKeyValPair(dictionary.ast)
|
||||
};
|
||||
},
|
||||
get(_1, dictionary) {
|
||||
return {
|
||||
http: {
|
||||
|
||||
@@ -17,7 +17,7 @@ const stripLastLine = (text) => {
|
||||
};
|
||||
|
||||
const jsonToBru = (json) => {
|
||||
const { meta, http, grpc, params, headers, metadata, auth, body, script, tests, vars, assertions, settings, docs } = json;
|
||||
const { meta, http, grpc, ws, params, headers, metadata, auth, body, script, tests, vars, assertions, settings, docs } = json;
|
||||
|
||||
|
||||
let bru = '';
|
||||
@@ -95,6 +95,36 @@ const jsonToBru = (json) => {
|
||||
bru += `
|
||||
}
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
if (ws && ws.url) {
|
||||
bru += `ws {
|
||||
url: ${ws.url}`;
|
||||
|
||||
if (ws.method && ws.method.length) {
|
||||
bru += `
|
||||
method: ${ws.method}`;
|
||||
}
|
||||
|
||||
if (ws.body && ws.body.length) {
|
||||
bru += `
|
||||
body: ${ws.body}`;
|
||||
}
|
||||
|
||||
if (ws.auth && ws.auth.length) {
|
||||
bru += `
|
||||
auth: ${ws.auth}`;
|
||||
}
|
||||
|
||||
if (ws.methodType && ws.methodType.length) {
|
||||
bru += `
|
||||
methodType: ${ws.methodType}`;
|
||||
}
|
||||
|
||||
bru += `
|
||||
}
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user