mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
Support SPARQL bodies
This commit is contained in:
parent
ff3321d643
commit
41abdbb7fa
@ -73,6 +73,15 @@ const RequestBodyMode = ({ item, collection }) => {
|
|||||||
>
|
>
|
||||||
XML
|
XML
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
className="dropdown-item"
|
||||||
|
onClick={() => {
|
||||||
|
dropdownTippyRef.current.hide();
|
||||||
|
onModeChange('sparql');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
SPARQL
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -28,17 +28,19 @@ const RequestBody = ({ item, collection }) => {
|
|||||||
const onRun = () => dispatch(sendRequest(item, collection.uid));
|
const onRun = () => dispatch(sendRequest(item, collection.uid));
|
||||||
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||||
|
|
||||||
if (['json', 'xml', 'text'].includes(bodyMode)) {
|
if (['json', 'xml', 'text', 'sparql'].includes(bodyMode)) {
|
||||||
let codeMirrorMode = {
|
let codeMirrorMode = {
|
||||||
json: 'application/ld+json',
|
json: 'application/ld+json',
|
||||||
text: 'application/text',
|
text: 'application/text',
|
||||||
xml: 'application/xml'
|
xml: 'application/xml',
|
||||||
|
sparql: 'application/sparql-query'
|
||||||
};
|
};
|
||||||
|
|
||||||
let bodyContent = {
|
let bodyContent = {
|
||||||
json: body.json,
|
json: body.json,
|
||||||
text: body.text,
|
text: body.text,
|
||||||
xml: body.xml
|
xml: body.xml,
|
||||||
|
sparql: body.sparql
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -14,6 +14,7 @@ const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODE
|
|||||||
if (!SERVER_RENDERED) {
|
if (!SERVER_RENDERED) {
|
||||||
require('codemirror/mode/javascript/javascript');
|
require('codemirror/mode/javascript/javascript');
|
||||||
require('codemirror/mode/xml/xml');
|
require('codemirror/mode/xml/xml');
|
||||||
|
require('codemirror/mode/sparql/sparql');
|
||||||
require('codemirror/addon/comment/comment');
|
require('codemirror/addon/comment/comment');
|
||||||
require('codemirror/addon/dialog/dialog');
|
require('codemirror/addon/dialog/dialog');
|
||||||
require('codemirror/addon/edit/closebrackets');
|
require('codemirror/addon/edit/closebrackets');
|
||||||
|
@ -602,6 +602,7 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
|
|||||||
json: null,
|
json: null,
|
||||||
text: null,
|
text: null,
|
||||||
xml: null,
|
xml: null,
|
||||||
|
sparql: null,
|
||||||
multipartForm: null,
|
multipartForm: null,
|
||||||
formUrlEncoded: null
|
formUrlEncoded: null
|
||||||
}
|
}
|
||||||
|
@ -692,6 +692,10 @@ export const collectionsSlice = createSlice({
|
|||||||
item.draft.request.body.xml = action.payload.content;
|
item.draft.request.body.xml = action.payload.content;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'sparql': {
|
||||||
|
item.draft.request.body.sparql = action.payload.content;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'formUrlEncoded': {
|
case 'formUrlEncoded': {
|
||||||
item.draft.request.body.formUrlEncoded = action.payload.content;
|
item.draft.request.body.formUrlEncoded = action.payload.content;
|
||||||
break;
|
break;
|
||||||
|
@ -284,6 +284,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
|
|||||||
text: si.draft.request.body.text,
|
text: si.draft.request.body.text,
|
||||||
xml: si.draft.request.body.xml,
|
xml: si.draft.request.body.xml,
|
||||||
graphql: si.draft.request.body.graphql,
|
graphql: si.draft.request.body.graphql,
|
||||||
|
sparql: si.draft.request.body.sparql,
|
||||||
formUrlEncoded: copyFormUrlEncodedParams(si.draft.request.body.formUrlEncoded),
|
formUrlEncoded: copyFormUrlEncodedParams(si.draft.request.body.formUrlEncoded),
|
||||||
multipartForm: copyMultipartFormParams(si.draft.request.body.multipartForm)
|
multipartForm: copyMultipartFormParams(si.draft.request.body.multipartForm)
|
||||||
},
|
},
|
||||||
@ -316,6 +317,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
|
|||||||
text: si.request.body.text,
|
text: si.request.body.text,
|
||||||
xml: si.request.body.xml,
|
xml: si.request.body.xml,
|
||||||
graphql: si.request.body.graphql,
|
graphql: si.request.body.graphql,
|
||||||
|
sparql: si.request.body.sparql,
|
||||||
formUrlEncoded: copyFormUrlEncodedParams(si.request.body.formUrlEncoded),
|
formUrlEncoded: copyFormUrlEncodedParams(si.request.body.formUrlEncoded),
|
||||||
multipartForm: copyMultipartFormParams(si.request.body.multipartForm)
|
multipartForm: copyMultipartFormParams(si.request.body.multipartForm)
|
||||||
},
|
},
|
||||||
@ -459,6 +461,10 @@ export const humanizeRequestBodyMode = (mode) => {
|
|||||||
label = 'XML';
|
label = 'XML';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'sparql': {
|
||||||
|
label = 'SPARQL';
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'formUrlEncoded': {
|
case 'formUrlEncoded': {
|
||||||
label = 'Form URL Encoded';
|
label = 'Form URL Encoded';
|
||||||
break;
|
break;
|
||||||
|
@ -24,7 +24,7 @@ const { outdentString } = require('../../v1/src/utils');
|
|||||||
const grammar = ohm.grammar(`Bru {
|
const grammar = ohm.grammar(`Bru {
|
||||||
BruFile = (meta | http | query | headers | auths | bodies | varsandassert | script | tests | docs)*
|
BruFile = (meta | http | query | headers | auths | bodies | varsandassert | script | tests | docs)*
|
||||||
auths = authbasic | authbearer
|
auths = authbasic | authbearer
|
||||||
bodies = bodyjson | bodytext | bodyxml | bodygraphql | bodygraphqlvars | bodyforms | body
|
bodies = bodyjson | bodytext | bodyxml | bodysparql | bodygraphql | bodygraphqlvars | bodyforms | body
|
||||||
bodyforms = bodyformurlencoded | bodymultipart
|
bodyforms = bodyformurlencoded | bodymultipart
|
||||||
|
|
||||||
nl = "\\r"? "\\n"
|
nl = "\\r"? "\\n"
|
||||||
@ -83,6 +83,7 @@ const grammar = ohm.grammar(`Bru {
|
|||||||
bodyjson = "body:json" st* "{" nl* textblock tagend
|
bodyjson = "body:json" st* "{" nl* textblock tagend
|
||||||
bodytext = "body:text" st* "{" nl* textblock tagend
|
bodytext = "body:text" st* "{" nl* textblock tagend
|
||||||
bodyxml = "body:xml" st* "{" nl* textblock tagend
|
bodyxml = "body:xml" st* "{" nl* textblock tagend
|
||||||
|
bodysparql = "body:sparql" st* "{" nl* textblock tagend
|
||||||
bodygraphql = "body:graphql" st* "{" nl* textblock tagend
|
bodygraphql = "body:graphql" st* "{" nl* textblock tagend
|
||||||
bodygraphqlvars = "body:graphql:vars" st* "{" nl* textblock tagend
|
bodygraphqlvars = "body:graphql:vars" st* "{" nl* textblock tagend
|
||||||
|
|
||||||
@ -366,6 +367,13 @@ const sem = grammar.createSemantics().addAttribute('ast', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
bodysparql(_1, _2, _3, _4, textblock, _5) {
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
sparql: outdentString(textblock.sourceString)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
bodygraphql(_1, _2, _3, _4, textblock, _5) {
|
bodygraphql(_1, _2, _3, _4, textblock, _5) {
|
||||||
return {
|
return {
|
||||||
body: {
|
body: {
|
||||||
|
@ -125,6 +125,14 @@ ${indentString(body.text)}
|
|||||||
${indentString(body.xml)}
|
${indentString(body.xml)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body && body.sparql && body.sparql.length) {
|
||||||
|
bru += `body:sparql {
|
||||||
|
${indentString(body.sparql)}
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,13 @@ body:xml {
|
|||||||
</xml>
|
</xml>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body:sparql {
|
||||||
|
SELECT * WHERE {
|
||||||
|
?subject ?predicate ?object .
|
||||||
|
}
|
||||||
|
LIMIT 10
|
||||||
|
}
|
||||||
|
|
||||||
body:form-urlencoded {
|
body:form-urlencoded {
|
||||||
apikey: secret
|
apikey: secret
|
||||||
numbers: +91998877665
|
numbers: +91998877665
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
"json": "{\n \"hello\": \"world\"\n}",
|
"json": "{\n \"hello\": \"world\"\n}",
|
||||||
"text": "This is a text body",
|
"text": "This is a text body",
|
||||||
"xml": "<xml>\n <name>John</name>\n <age>30</age>\n</xml>",
|
"xml": "<xml>\n <name>John</name>\n <age>30</age>\n</xml>",
|
||||||
|
"sparql": "SELECT * WHERE {\n ?subject ?predicate ?object .\n}\nLIMIT 10",
|
||||||
"graphql": {
|
"graphql": {
|
||||||
"query": "{\n launchesPast {\n launch_site {\n site_name\n }\n launch_success\n }\n}",
|
"query": "{\n launchesPast {\n launch_site {\n site_name\n }\n launch_success\n }\n}",
|
||||||
"variables": "{\n \"limit\": 5\n}"
|
"variables": "{\n \"limit\": 5\n}"
|
||||||
|
@ -57,11 +57,12 @@ const graphqlBodySchema = Yup.object({
|
|||||||
|
|
||||||
const requestBodySchema = Yup.object({
|
const requestBodySchema = Yup.object({
|
||||||
mode: Yup.string()
|
mode: Yup.string()
|
||||||
.oneOf(['none', 'json', 'text', 'xml', 'formUrlEncoded', 'multipartForm', 'graphql'])
|
.oneOf(['none', 'json', 'text', 'xml', 'formUrlEncoded', 'multipartForm', 'graphql', 'sparql'])
|
||||||
.required('mode is required'),
|
.required('mode is required'),
|
||||||
json: Yup.string().nullable(),
|
json: Yup.string().nullable(),
|
||||||
text: Yup.string().nullable(),
|
text: Yup.string().nullable(),
|
||||||
xml: Yup.string().nullable(),
|
xml: Yup.string().nullable(),
|
||||||
|
sparql: Yup.string().nullable(),
|
||||||
formUrlEncoded: Yup.array().of(keyValueSchema).nullable(),
|
formUrlEncoded: Yup.array().of(keyValueSchema).nullable(),
|
||||||
multipartForm: Yup.array().of(keyValueSchema).nullable(),
|
multipartForm: Yup.array().of(keyValueSchema).nullable(),
|
||||||
graphql: graphqlBodySchema.nullable()
|
graphql: graphqlBodySchema.nullable()
|
||||||
|
Loading…
Reference in New Issue
Block a user