Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,74 @@ exports[`should use inputs from CLI and env 1`] = `
    ✓ schema check


✓ GET /museum-hours - step test-default-input

    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/museum-hours?organizationId=acme-inc
    Request Headers:
      accept: application/json, application/problem+json
      authorization: Basic Og==


    Response status code: 200
    Response time: <test> ms
    Response Body:
      [
       {
       "date": "2023-09-11",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-12",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-13",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-14",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-15",
       "timeOpen": "10:00",
       "timeClose": "16:00"
       },
       {
       "date": "2023-09-18",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-19",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-20",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-21",
       "timeOpen": "09:00",
       "timeClose": "18:00"
       },
       {
       "date": "2023-09-22",
       "timeOpen": "10:00",
       "timeClose": "16:00"
       }
      ]

    ✓ status code check - $statusCode in [200, 400, 404]
    ✓ content-type check
    ✓ schema check

────────────────────────────────────────────────────────────────────────────────

Running workflow inputs-with-cli-and-env.yaml / events-crud
Expand Down Expand Up @@ -162,8 +230,8 @@ exports[`should use inputs from CLI and env 1`] = `
  Summary for inputs-with-cli-and-env.yaml

  Workflows: 2 passed, 2 total
  Steps: 3 passed, 3 total
  Checks: 13 passed, 13 total
  Steps: 4 passed, 4 total
  Checks: 16 passed, 16 total
  Time: <test>ms


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ workflows:
properties:
AUTH_TOKEN:
type: string
organizationId:
type: string
default: acme-inc
description: >-
This workflow demonstrates how to get the museum opening hours and buy tickets.
parameters:
Expand All @@ -44,6 +47,12 @@ workflows:
workflowId: $sourceDescriptions.tickets-from-museum-api.workflows.get-museum-tickets
outputs:
ticketId: $outputs.ticketId
- stepId: test-default-input
operationId: museum-api.getMuseumHours
parameters:
- in: query
name: organizationId
value: $inputs.env.organizationId
- workflowId: events-crud
inputs:
type: object
Expand Down
12 changes: 12 additions & 0 deletions __tests__/respect/local-json-server/local-json-server.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { spawn } from 'child_process';
import { getParams, getCommandOutput } from '../utils';
import { join } from 'path';
import * as fs from 'fs';

const dbPath = join(__dirname, 'fake-db.json');

describe('local-json-server', () => {
let serverProcess: any;
let originalData: string | undefined;

beforeAll(async () => {
// Start json-server
serverProcess = spawn('npm', ['run', 'json-server'], { detached: true });

// Store original state of fake-bd.json
originalData = fs.readFileSync(dbPath, 'utf8');
});

afterAll(() => {
// Kill the process group to ensure child processes are cleaned up
process.kill(-serverProcess.pid);

// Restore original state
if (originalData) {
fs.writeFileSync(dbPath, originalData);
}
});

test('local-json-server test case', () => {
Expand Down
131 changes: 131 additions & 0 deletions __tests__/respect/replacements/__snapshots__/replacements.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should replace values in the request body 1`] = `
"────────────────────────────────────────────────────────────────────────────────

Running workflow replacements.arazzo.yaml / replacements

✓ GET /special-events/{eventId} - step first-step

    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events/dad4bce8-f5cb-4078-a211-995864315e39
    Request Headers:
      accept: application/json, application/problem+json
      authorization: Basic Og==


    Response status code: 200
    Response time: <test> ms
    Response Body:
      {
       "eventId": "6744a0da-4121-49cd-8479-f8cc20526495",
       "name": "Time Traveler Tea Party",
       "location": "Temporal Tearoom",
       "eventDescription": "Sip tea with important historical figures.",
       "dates": [
       "2023-11-18",
       "2023-11-25",
       "2023-12-02"
       ],
       "price": 60
      }

    ✓ status code check - $statusCode in [200, 400, 404]
    ✓ content-type check
    ✓ schema check

✓ POST /tickets - step step-with-json-replacements

    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/tickets
    Request Headers:
      content-type: application/json
      accept: application/json, application/problem+json
      authorization: Basic Og==
    Request Body:
      {
       "eventId": "my-custom-event-id",
       "name": "Time Traveler Tea Party",
       "location": "Time Traveler Tea Party",
       "eventDescription": "Sip tea with important historical figures.",
       "dates": [
       "2025-01-01"
       ],
       "price": 60
      }


    Response status code: 400
    Response time: <test> ms
    Response Body:
      {
       "type": "object",
       "title": "Error validating body. data must have required property 'ticketType', data must have required property 'ticketDate', data must have required property 'email', data/eventId must match format \\"uuid\\""
      }

    ✓ status code check - $statusCode in [201, 400, 404]
    ✓ content-type check
    ✓ schema check

✓ PATCH /special-events/{eventId} - step step-with-form-urlencoded-replacements

    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events/dad4bce8-f5cb-4078-a211-995864315e39
    Request Headers:
      content-type: application/x-www-form-urlencoded
      accept: application/json, application/problem+json
      authorization: Basic Og==
    Request Body:
      "name=Time+Traveler+Tea+Party&location=New+York"


    Response status code: 400
    Response time: <test> ms
    Response Body:
      {
       "type": "object",
       "title": "Media type \\"application/x-www-form-urlencoded\\" is not supported"
      }

    ✓ status code check - $statusCode in [200, 400, 404]
    ✓ content-type check
    ✓ schema check

✓ PATCH /special-events/{eventId} - step step-with-form-urlencoded-replacements-2

    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events/dad4bce8-f5cb-4078-a211-995864315e39
    Request Headers:
      content-type: application/x-www-form-urlencoded
      accept: application/json, application/problem+json
      authorization: Basic Og==
    Request Body:
      "name=Time+Traveler+Tea+Party&location=Jakarta"


    Response status code: 400
    Response time: <test> ms
    Response Body:
      {
       "type": "object",
       "title": "Media type \\"application/x-www-form-urlencoded\\" is not supported"
      }

    ✓ status code check - $statusCode in [200, 400, 404]
    ✓ content-type check
    ✓ schema check


  Summary for replacements.arazzo.yaml

  Workflows: 1 passed, 1 total
  Steps: 4 passed, 4 total
  Checks: 12 passed, 12 total
  Time: <test>ms


┌──────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┐
│ Filename │ Workflows │ Passed │ Failed │ Warnings │
├──────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┤
│ ✓ replacements.arazzo.yaml │ 1 │ 1 │ - │ - │
└──────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┘


"
`;
Loading
Loading