mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 13:15:40 +00:00
feat: add function in bruno converters package (#4669)
* feat: add function in bruno converters package * add: example for openapi yaml to bruno conversion * add: converting json to yaml in converters * fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import each from 'lodash/each';
|
||||
import get from 'lodash/get';
|
||||
import jsyaml from 'js-yaml';
|
||||
import { validateSchema, transformItemsInCollection, hydrateSeqInCollection, uuid } from '../common';
|
||||
|
||||
const parseGraphQL = (text) => {
|
||||
@@ -288,6 +289,9 @@ const parseInsomniaCollection = (data) => {
|
||||
|
||||
export const insomniaToBruno = (insomniaCollection) => {
|
||||
try {
|
||||
if(typeof insomniaCollection !== 'object') {
|
||||
insomniaCollection = jsyaml.load(insomniaCollection);
|
||||
}
|
||||
let collection;
|
||||
if (isInsomniaV5Export(insomniaCollection)) {
|
||||
collection = parseInsomniaV5Collection(insomniaCollection);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import each from 'lodash/each';
|
||||
import get from 'lodash/get';
|
||||
import jsyaml from 'js-yaml';
|
||||
import { validateSchema, transformItemsInCollection, hydrateSeqInCollection, uuid } from '../common';
|
||||
|
||||
const ensureUrl = (url) => {
|
||||
@@ -422,6 +423,10 @@ export const parseOpenApiCollection = (data) => {
|
||||
|
||||
export const openApiToBruno = (openApiSpecification) => {
|
||||
try {
|
||||
if(typeof openApiSpecification !== 'object') {
|
||||
openApiSpecification = jsyaml.load(openApiSpecification);
|
||||
}
|
||||
|
||||
const collection = parseOpenApiCollection(openApiSpecification);
|
||||
const transformedCollection = transformItemsInCollection(collection);
|
||||
const hydratedCollection = hydrateSeqInCollection(transformedCollection);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
import insomniaToBruno from '../../src/insomnia/insomnia-to-bruno';
|
||||
import jsyaml from 'js-yaml';
|
||||
|
||||
describe('insomnia-collection', () => {
|
||||
it('should correctly import a valid Insomnia v5 collection file', async () => {
|
||||
const brunoCollection = insomniaToBruno(jsyaml.load(insomniaCollection));
|
||||
const brunoCollection = insomniaToBruno(insomniaCollection);
|
||||
|
||||
expect(brunoCollection).toMatchObject(expectedOutput)
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import jsyaml from 'js-yaml';
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
import openApiToBruno from '../../src/openapi/openapi-to-bruno';
|
||||
|
||||
describe('openapi-collection', () => {
|
||||
it('should correctly import a valid OpenAPI file', async () => {
|
||||
const openApiSpecification = jsyaml.load(openApiCollectionString);
|
||||
const brunoCollection = openApiToBruno(openApiSpecification);
|
||||
const brunoCollection = openApiToBruno(openApiCollectionString);
|
||||
|
||||
expect(brunoCollection).toMatchObject(expectedOutput);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user