Service Virtualization
Documentation Home
  • Overview
  • Getting-Started-With-Service-Virtualization
    • Intro-to-SV
    • Creating SV Project
  • Dynamic-Assets
    • Advanced Mode
    • Building Dynamic Asset
    • Dynamic Asset
  • Manual-Assets
    • Build Asset Manually
    • Build New Request
    • Import Manual Asset
    • Manage and Send Request
    • Manual Asset
  • Advanced-Features
    • Global Variable
    • Parameterization
    • Strict Mode
  • FAQs
    • FAQs
Powered by GitBook
On this page
  • Contents
  • What Advanced Mode Offers?
  • Create Dynamic Asset with Advanced Mode
  • Generate APIs
  • Advanced Data Templates
  • Related Content
  1. Dynamic-Assets

Advanced Mode

Last updated 1 year ago

Since you're familiar with Basic Mode, Let's explore Advanced Mode of Dynamic API Creation.

Contents


What Advanced Mode Offers?

In the Basic Mode, you're able to create dummy real-time data, but you can't produce dummy real-time data in the shape of nested JSON objects or repeated nested JSON objects. To handle this situation differently, we've introduced the Advanced Mode for Dynamic APIs. This mode allows you to provide a template for the data you wish to make.

Pretty amazing, isn't it? Let's dive deeper into this.


Create Dynamic Asset with Advanced Mode

Once we switch to Advanced mode you'll Changes like Space to give a template for data generation instead of dropdown selection.

You can give the desired template and click on the "Generate JSON" button to generate data as shown below.


Generate APIs

Once done with data generation, You can click on the "Generate API" button on the right panel as shown below.

Once APIs are created, You can start using APIs.

The way Advanced mode JSON functions is different from Basic mode. In Basic mode, it's an array of objects, allowing users to perform various operations. However, in Advanced mode, if there are nested and child objects, only GET calls will function.


Advanced Data Templates

Below is a guideline for writing a JSON template for Advanced mode to create Dynamic JSON data

  • Write a simple template

    [
        {{#repeat 5}}
            {
                "id": {{@index}},
                "name": "{{firstName}} {{lastName}}",
                "work": "{{company}}",
                "email": "{{email}}",
                "dob": "{{date '2000-01-01' '2021-12-31'}}",
                "address": "{{int 1 100}} {{street}}",
                "city": "{{city}}",
                "optedin": {{boolean}}
            }
        {{/repeat}}
    ]
    
  • Write a simple template with Nested JSON

    {
        "users": [
            {
            "name": "{{firstName}} {{lastName}}",
            "work": "{{company}}",
            "email": "{{email}}",
            "dob": "{{date '2000-01-01' '2021-12-31'}}",
            "address": "{{int 1 100}} {{street}}",
            "city": "{{city}}",
            "optedin": {{boolean}}
            }
        ]
    }
    
  • Write template with repetition

    {
        "users": [
            {{#repeat 2}}
            {
            "id": {{@index}},
            "name": "{{firstName}} {{lastName}}",
            "work": "{{company}}",
            "email": "{{email}}",
            "dob": "{{date '2000-01-01' '2021-12-31'}}",
            "address": "{{int 1 100}} {{street}}",
            "city": "{{city}}",
            "optedin": {{boolean}}
            }
            {{/repeat}}
        ]
    }
    
  • Write a template with Nested JSON Objects and repetition

    {
        "users": [
            {{#repeat 2}}
            {
            "id": {{@index}},
            "name": "{{firstName}} {{lastName}}",
            "work": "{{company}}",
            "email": "{{email}}",
            "dob": "{{date '2000-01-01' '2021-12-31'}}",
            "address": "{{int 1 100}} {{street}}",
            "city": "{{city}}",
            "optedin": {{boolean}}
            }
            {{/repeat}}
        ],
        "coordinates": {
            "x": {{float -50 50 '0.00'}},
            "y": {{float -25 25 '0.00'}}
        },
        "price": "${{int 0 99999 '0,0'}}"
    }

Add Different Data Types other than those mentioned in the above templates

  • Boolean

    {{boolean}}

    Generates a random true or false value.

  • Title

    {{title}}

    Generates a random title prefix, from a predefined list, such as "Mr", "Mrs", "Dr", etc.

  • Domain

    {{domain}}

    Generates a random domain name in the format "domain.tld", from a predefined list.

  • Country

    {{country}}

    Generates a random country name, from a predefined list based on ISO 3166-1.

  • Country code

    {{countryCode}}

    Generates a random 2-character country code, from a predefined list based on ISO 3166-1.

  • Zipcode

    {{zipcode}}

    Generates a random US-style 5-digit zipcode.

  • Postcode

    {{postcode}}

    Generates a random UK-style postcode in the format AB9 9CD.

  • Phone number

    {{phone [format]}}

    format?: string Formatting string (optional, default is xxx-xxx-xxxx)

    Generates a random phone number in the format xxx-xxx-xxxx, for example, "123-456-7890". To use a different format pass a string to the format parameter containing a series of lowercase "x" characters for each random integer.

    Generate a random phone number in the default format {{phone}} --? 445-295-1044

    Generate a random phone number with a custom format {{phone "+64 (x) xxx xxxx"}} --? +64 (5) 883 4711

  • Color

    {{color}}

    Generates a random CSS color name from a predefined list, such as "forestgreen", "black", etc.

  • Hex color

    {{hexColor}}

    Generates a random hexadecimal color value with an optional leading hash symbol.

  • GUID

    {{guid}}

    Generates a random 32-digit GUID.

  • IPv4 address

    {{ipv4}}

    Generates a random IPv4 address.

  • IPv6 address

    {{ipv6}}

    Generates a random IPv4 address.

  • Latitude

    {{lat}}

    Generates a random latitude from -90 to +90, to 6 decimal places (roughly 10cm of precision).

  • Longitude

    {{long}}

    Generates a random longitude from -180 to +180, to 6 decimal places (roughly 10cm of precision).

  • Random item

    {{random ...items}}

    items: string | number One or more parameters from which to pick a random item (required)

    Picks a random item from the given parameters. This is a convenient way to create small, inline random lists of your own.

    Randomly pick one of the provided strings {{random 'North' 'South' 'East' 'West'}} --> South

    You can also provide numbers {{random 50 100 150 200}} --> 150

  • Lorem ipsum

    {{lorem [wordCount]}}

    wordcount?: number Number of words to generate (optional, default is 25)

    {{lorem min=number max=number}}

    min: number Minimum range for the random word count (required)

    max: number Maximum range for the random word count (required)

    There are two ways this helper can be used. Both generate random sentences of lorem ipsum text with occasional punctuation (commas and periods/full stops).

    Generates 25 words of lorem ipsum {{lorem}} --> Amet vel aliquam laoreet accumsan adipiscing velit... (etc)

    Generates 5 words of lorem ipsum {{lorem 5}} --> Orci nisi laoreet maximus dictum.

    Generates a random number of words between 10 and 20 {{lorem min=10 max=20}} --> Felis velit aliquam aliquet sollicitudin consequat... (etc)


Related Content

You can try out Different templates for generating data. to check

Strict Mode
Global Variable
Parameterization
Click here
Advanced Mode
What Advanced Mode Offers?
Create Dynamic Asset with Advanced Mode
Generate APIs
Advanced Data Templates
Related Content
AdvancedMode
GeneratedData
GenerateAPIButtonForAdvanced