Files
bruno/packages/bruno-lang/v2/tests/examples/fixtures/json/complex-with-auth.json
sanish chirayath 68cbb7d9df Feat/add import export support for examples (#5936)
* feat: enhance Bru grammar to support response blocks and examples

- Added new grammar rules for response headers, status, and body types (JSON, XML, text).
- Introduced parsing logic for example blocks, allowing multiple examples with various body types.
- Implemented tests for example parsing, including edge cases and complex examples with authentication.
- Created fixture files for simple and complex examples to validate parsing functionality.

feat: extend jsonToBru functionality to support response handling and examples

- Updated jsonToBru to include parsing for response headers, status, and body types (JSON, XML, text).
- Enhanced example handling to support multiple examples with various body types.
- Added comprehensive tests for example parsing, including edge cases and complex scenarios with authentication.
- Created fixture files for testing the new features and validating parsing functionality.

move: files to fixtures folder

refactor: simplify response body handling in Bru grammar and JSON conversion

- Removed specific body type handling (JSON, XML, text) from grammar and semantics.
- Updated response body parsing in jsonToBru to handle a unified response body format.
- Adjusted tests and fixtures to reflect changes in response body structure, ensuring compatibility with the new format.

feat: add response bookmarking functionality to ResponsePane

- Introduced ResponseBookmark component to allow users to save responses as examples.
- Added NameExampleModal for naming saved examples.
- Updated ResponsePane to include the new bookmarking feature.
- Implemented Redux actions to manage response examples in the collections state.
- Enhanced CollectionItem to display saved examples and allow for expansion.

fix: remove unnecessary padding from ExampleItem component

feat: implement delete and rename functionality for examples in ExampleItem component

- Added DeleteExampleModal for confirming deletion of examples.
- Integrated modal for renaming examples with state management.
- Enhanced ExampleItem to handle example deletion and renaming through modals.
- Updated Redux actions to support example updates and deletions in the collections state.

fix: example writing to  disc properly

fix: example parsing errors

fix: request with example parsing error

fix: handle examples in collections and requests

feat: implement response example functionality in the application

- Added ResponseExample component to handle displaying and editing response examples.
- Integrated ResponseExampleRequestPane and ResponseExampleResponsePane for structured request and response handling.
- Enhanced RequestTabPanel and RequestTab components to support response-example tabs.
- Introduced new styled components for better UI/UX in response examples.
- Updated theme files to include styles for response examples.
- Implemented URL bar for editing request URLs in response examples.
- Added functionality for managing headers and parameters in response examples.
- Improved overall structure and organization of response example components.

add styles for example url bar

feat: add Checkbox component and Table-v2 for enhanced UI

- Introduced a new Checkbox component for better user interaction in forms.
- Added Table-v2 component to improve table rendering and resizing functionality.
- Updated existing components to utilize the new Checkbox and Table-v2 for managing headers and parameters in response examples.
- Enhanced styling for better visual consistency across components.
- Updated theme files to include styles for the new components.

feat: implement custom scrollbar styles for response example components

fix: features

add actions , view more

feat: enhance response example functionality

- Added GenerateCodeItem component for generating code snippets from response examples.
- Integrated modal for code generation within ResponseExample component.
- Updated ResponseExampleTopBar to handle example name and description editing.
- Improved state management for response examples, including new actions for updating names and descriptions.
- Enhanced ResponseExampleRequestPane to support editing and saving request details.
- Refactored URL handling in ResponseExampleUrlBar to utilize example-specific data.
- Improved overall user experience with better UI elements and state management.

feat: enhance response example management and UI components

feat: enhance editing capabilities in response example components

feat: update multipart form parameter handling in response examples

feat: refactor response example parameter handling and enhance UI interactions

feat: introduce RadioButton component and update Checkbox usage in response examples

fix: styles

fix radio button styling

fixed radio button styles

feat: add create example from sidebar

feat: enhance ResponseExample components with layout adjustments and new HeightBoundContainer

feat: add Checkbox and RadioButton components with comprehensive tests for rendering, user interactions, and accessibility

feat: playwright test csaes

rm: comments

fix: linting

fix: tests

refactor: update response example tests and enhance functionality

fix: tests

fix: e2e-tests

refactor: implement hasRequestChanges utility for better change detection

rm: console

rm: consoles

fix: lint

fix: tests

fix: response header disabled by default issue

Feat/with bru example parser (#5892)

* fix: response header disabled by default issue

feat: new parsing logic

fix: change test cases to accomodate new brulang

add: path params features

rm:consoles

six: make tab permanent on double click

fix width

feat: add status editing

feat: review fixes

review fixes

fix: review fixes

fix: post review

mv: test files

fix: review

* fix: lint

* fix: review comments

* fix: icons folder strcuture

fix: tests

fix: lint

fix: unit tests

feat: body mode selector

fix: close all collections

rm: example

feat added tests. lang change

feat: add custom status text

fix: status update

feat: add body mode, update tests

add default name prefilled for example

fix: active tab styles, prefilled name, text fixes

fix : pkg lock

fix: review

fix: review comments

fix: hide cursor when readonly

fix: height

fix: null body

fix: response body parsing

fix: test cases

feat: add method support for examples

fix: reponse parsing

fix: update response body type when content type is updated

rm : commented code

feat: update parser logic

fix: organize files

feat: enhance examples handling in collection export and import

feat: postman imports fro examples

feat: enhance OpenAPI import functionality to support examples

feat: support postman export

fix: postman export import

fix: open api tests, remove requestbody related logic

rm: examples

fix:  move common attributes files

ui fixes

fix: clone issue

fix: create example from request menu

review fixes

more review fixes

mv: files, fix mode req error

organize files

fix:tests

fix: save dot issue

fix: bugs

fix: postman export

fix: import path params

* chore:improve modal handling in environment and response example tests

fix: test issues resolved

* chore: update response example tests to use new fixture files and improve cleanup logic

---------

Co-authored-by: Abhishek S Lal <abhishek@usebruno.com>
Co-authored-by: Bijin Bruno <bijin@usebruno.com>
2025-11-01 05:56:11 +05:30

211 lines
7.2 KiB
JSON

{
"meta": {
"name": "Complex API with Auth",
"type": "http",
"seq": "1"
},
"http": {
"method": "post",
"url": "https://api.example.com/users",
"body": "json",
"auth": "bearer"
},
"headers": [
{
"name": "content-type",
"value": "application/json",
"enabled": true
},
{
"name": "x-api-key",
"value": "my-secret-key",
"enabled": true
},
{
"name": "x-request-id",
"value": "{{$uuid}}",
"enabled": true
}
],
"params": [
{
"name": "include",
"value": "details",
"enabled": true,
"type": "query"
},
{
"name": "format",
"value": "json",
"enabled": true,
"type": "query"
},
{
"name": "id",
"value": "123",
"enabled": true,
"type": "path"
},
{
"name": "status",
"value": "active",
"enabled": true,
"type": "path"
}
],
"auth": {
"basic": {
"username": "admin",
"password": "secret123"
},
"bearer": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHluKJe2vncyz4h4SH6FSS7YOKIx"
},
"apikey": {
"key": "x-api-key",
"value": "api-secret-key-12345",
"placement": "header"
}
},
"body": {
"json": "{\n \"username\": \"johndoe\",\n \"email\": \"john@example.com\",\n \"profile\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"age\": 30\n },\n \"preferences\": {\n \"theme\": \"dark\",\n \"notifications\": true\n },\n \"tags\": [\"admin\", \"user\", \"verified\"]\n}"
},
"script": {
"req": "const timestamp = Date.now();\nbru.setVar(\"request_timestamp\", timestamp);\nbru.setVar(\"signature\", crypto.createHash('md5').update(timestamp.toString()).digest('hex'));"
},
"vars": {
"req": [
{
"name": "user_id",
"value": "12345",
"enabled": true,
"local": false
},
{
"name": "environment",
"value": "production",
"enabled": true,
"local": false
}
],
"res": [
{
"name": "response_id",
"value": "{{res.id}}",
"enabled": true,
"local": false
},
{
"name": "processed_at",
"value": "{{$timestamp}}",
"enabled": true,
"local": false
}
]
},
"tests": "test(\"Response should be 201\", function() {\n expect(res.getStatus()).to.eql(201);\n});\n\ntest(\"Response should have user data\", function() {\n const body = res.getBody();\n expect(body.username).to.be.ok;\n expect(body.email).to.be.ok;\n});",
"docs": "This endpoint creates a new user account.\nRequires authentication via Bearer token or API key.\nSupports nested JSON structures with arrays.",
"examples": [
{
"name": "Basic User Creation",
"description": "Creates a new user with minimal required fields",
"request": {
"url": "https://api.example.com/users",
"method": "post",
"body": {
"mode": "json",
"json": "{\n \"username\": \"newuser\",\n \"email\": \"newuser@example.com\",\n \"password\": \"SecurePass123!\"\n}"
},
"headers": [
{
"name": "authorization",
"value": "\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\",",
"enabled": true
},
{
"name": "content-type",
"value": "\"application/json\"",
"enabled": true
}
]
},
"response": {
"status": "201",
"statusText": "OK",
"body": {
"type": "json",
"content": "{\n \"id\": 100,\n \"username\": \"newuser\",\n \"email\": \"newuser@example.com\",\n \"created_at\": \"2024-01-15T10:30:00Z\",\n \"status\": \"active\"\n}"
}
}
},
{
"name": "Advanced User with Profile",
"description": "Creates a user with complete profile information and nested data",
"request": {
"url": "https://api.example.com/users",
"method": "post",
"body": {
"mode": "json",
"json": "{\n \"username\": \"developer\",\n \"email\": \"dev@example.com\",\n \"password\": \"DevPass2024!\",\n \"profile\": {\n \"firstName\": \"Jane\",\n \"lastName\": \"Developer\",\n \"bio\": \"Software engineer passionate about APIs\",\n \"location\": {\n \"city\": \"San Francisco\",\n \"country\": \"USA\",\n \"timezone\": \"America/Los_Angeles\"\n },\n \"social\": {\n \"github\": \"jandeveloper\",\n \"twitter\": \"@jane_dev\"\n }\n },\n \"skills\": [\"JavaScript\", \"Node.js\", \"React\", \"API Design\"],\n \"experience\": 5,\n \"preferences\": {\n \"theme\": \"dark\",\n \"language\": \"en\",\n \"notifications\": {\n \"email\": true,\n \"push\": true,\n \"sms\": false\n }\n }\n}"
},
"headers": [
{
"name": "authorization",
"value": "\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\",",
"enabled": true
},
{
"name": "content-type",
"value": "\"application/json\",",
"enabled": true
},
{
"name": "x-api-key",
"value": "\"advanced-api-key-45678\"",
"enabled": true
}
]
},
"response": {
"status": "201",
"statusText": "OK",
"body": {
"type": "json",
"content": "{\n \"id\": 101,\n \"username\": \"developer\",\n \"email\": \"dev@example.com\",\n \"profile\": {\n \"firstName\": \"Jane\",\n \"lastName\": \"Developer\",\n \"bio\": \"Software engineer passionate about APIs\",\n \"location\": {\n \"city\": \"San Francisco\",\n \"country\": \"USA\",\n \"timezone\": \"America/Los_Angeles\"\n }\n },\n \"skills\": [\"JavaScript\", \"Node.js\", \"React\", \"API Design\"],\n \"experience\": 5,\n \"created_at\": \"2024-01-15T12:45:30Z\",\n \"status\": \"active\",\n \"verified\": false\n}"
}
}
},
{
"name": "XML Data Example",
"description": "Example with XML format and complex structure",
"request": {
"url": "https://api.example.com/users/xml",
"method": "post",
"body": {
"mode": "xml",
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>\n <username>xmluser</username>\n <email>xml@example.com</email>\n <profile>\n <firstName>XML</firstName>\n <lastName>User</lastName>\n </profile>\n</user>"
},
"headers": [
{
"name": "content-type",
"value": "\"application/xml\",",
"enabled": true
},
{
"name": "authorization",
"value": "\"Basic YWRtaW46cGFzc3dvcmQ=\"",
"enabled": true
}
]
},
"response": {
"status": "201",
"statusText": "OK",
"body": {
"type": "xml",
"content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n <id>102</id>\n <status>created</status>\n <user>\n <username>xmluser</username>\n <email>xml@example.com</email>\n </user>\n</response>"
}
}
}
]
}