Skip to content

Commit

Permalink
- Updating references to _data and _tests to _examples
Browse files Browse the repository at this point in the history
- Fixing minor typos
  • Loading branch information
harikrishnan83 committed Jul 3, 2024
1 parent 3692988 commit 4a40f8b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
42 changes: 21 additions & 21 deletions archive/service_virtualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Feature: Square API
A useful stub might be that when we post the number 5, we get 25 back.

Follow these steps:
- Create a directory named square_data, in the same directory as the square.spec file.
- Create a directory named square_examples, in the same directory as the square.spec file.
- In that directory, create a json file, name it what you like. For example, square_of_5.json
- Put in that file the following text:

Expand Down Expand Up @@ -149,7 +149,7 @@ The directory structure now looks like this:
```
|
\_ square.spec [file]
\_ square_data [directory]
\_ square_examples [directory]
|
\_ square_of_5.json [file]
\_ square_of_6.json [file]
Expand All @@ -160,12 +160,12 @@ Try running the stub now:
```shell
> {{ site.spec_cmd }} stub square.spec
Reading the stub files below:
./square_data/square_of_5.json
./square_data/square_of_6.json
./square_examples/square_of_5.json
./square_examples/square_of_6.json
Stub server is running on http://localhost:9000. Ctrl + C to stop.
```

Specmatic looks for a directory with the filename of the specmatic file, + the suffix "_data". It found it in this case, and loaded it.
Specmatic looks for a directory with the filename of the specmatic file, + the suffix "_examples". It found it in this case, and loaded it.

In another tab, let's post 5 to the stub and see what happens:

Expand Down Expand Up @@ -207,7 +207,7 @@ Feature: Customer API
Then status 200
```

Create a directory named customer_data, and put this stub in it:
Create a directory named customer_examples, and put this stub in it:

```json
// filename: new_customer.json
Expand All @@ -231,7 +231,7 @@ Run the stub:
```shell
> {{ site.spec_cmd }} stub customer.spec
Reading the stub files below:
/path/to/customer_data/new_customer.json
/path/to/customer_examples/new_customer.json
Stub server is running on http://localhost:9000. Ctrl + C to stop.
```

Expand Down Expand Up @@ -260,7 +260,7 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and put this stub in it:
Create a directory named customer_examples, and put this stub in it:

```json
// filename: new_customer.json
Expand All @@ -285,8 +285,8 @@ Run the stub:
```
> {{ site.spec_cmd }} stub customer.spec
Reading the stub files below:
/path/to/customer_data/new_customer.json
/path/to/customer_data/new_customer.json didn't match customer.spec
/path/to/customer_examples/new_customer.json
/path/to/customer_examples/new_customer.json didn't match customer.spec
In scenario "Add customer"
>> REQUEST.BODY.address
Expand Down Expand Up @@ -325,7 +325,7 @@ Feature: Square API

Create a stub for it:

File: square_data/stub.json
File: square_examples/stub.json
```json
{
"http-request": {
Expand All @@ -345,9 +345,9 @@ Run the stub:
```bash
> specmatic stub square.spec
Loading square.spec
Loading stub expectations from /Users/joelrosario/tmp/square_data
Loading stub expectations from /Users/joelrosario/tmp/square_examples
Reading the following stub files:
/Users/joelrosario/tmp/square_data/stub.json
/Users/joelrosario/tmp/square_examples/stub.json
Stub server is running on http://0.0.0.0:9000. Ctrl + C to stop.
```

Expand Down Expand Up @@ -390,7 +390,7 @@ If you want to stub out multiple contracts together:
> {{ site.spec_cmd }} stub customer.spec order.spec
```

If the customer_data and order_data directories exist, stub data will be loaded from them automatically.
If the customer_examples and order_examples directories exist, stub data will be loaded from them automatically.

### Lenient stubbing

Expand All @@ -408,10 +408,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and inside it a file named stub.json, with the following contents:
Create a directory named customer_examples, and inside it a file named stub.json, with the following contents:

```json
// filename: customer_data/stub.json
// filename: customer_examples/stub.json
{
"http-request": {
"method": "GET",
Expand Down Expand Up @@ -473,10 +473,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and inside it a file named stub.json, with the following contents:
Create a directory named customer_examples, and inside it a file named stub.json, with the following contents:

```json
// filename: customer_data/stub.json
// filename: customer_examples/stub.json
{
"http-request": {
"method": "GET",
Expand Down Expand Up @@ -523,7 +523,7 @@ Feature: Contract for the petstore service

The path parameter id and query parameter name can be setup in the corresponding data json file with below syntax.

File: petstore_data/petstore.json
File: petstore_examples/petstore.json
```json
{
"http-request": {
Expand Down Expand Up @@ -632,10 +632,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and a file named stub.json within it that contains this:
Create a directory named customer_examples, and a file named stub.json within it that contains this:

```json
// filepath: customer_data/stub.json
// filepath: customer_examples/stub.json
{
"http-request": {
"method": "POST",
Expand Down
12 changes: 6 additions & 6 deletions documentation/contract_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ You can store test data in json files side-by-side to be used in the contract te

Let's try it out. Use the following specification (it is the same specification from the above section without the inline examples):

*filename: employees_without_examples.yaml*
*filename: employees.yaml*

```yaml
openapi: 3.0.0
Expand Down Expand Up @@ -302,7 +302,7 @@ components:
type: string
```

Create a directory named `employees_without_examples_tests`, and store the following json files in it:
Create a directory named `employees_examples`, and store the following json files in it:

*filename: create_employee.json*
```json
Expand Down Expand Up @@ -368,9 +368,9 @@ Create a directory named `employees_without_examples_tests`, and store the follo
}
```

Let us now run `employees_without_examples.yaml` as a test against the sample application.
Let us now run `employees.yaml` as a test against the sample application.

```{{ site.spec_cmd }} test --testBaseURL https://my-json-server.typicode.com employees_without_examples.yaml```
```{{ site.spec_cmd }} test --testBaseURL https://my-json-server.typicode.com employees.yaml```

The results will be exactly the same as the previous run.

Expand Down Expand Up @@ -1145,7 +1145,7 @@ Specmatic will validate the test data against the specification before using it.

##### Example with a path parameter
To convert the `GET_DETAILS` test from [api_order_with_oauth_v1.yaml](https://github.com/znsio/specmatic-order-contracts/blob/main/in/specmatic/examples/store/api_order_with_oauth_v1.yaml) into an externalised test:
* Create a new directory named `api_order_with_oauth_v1_tests` in the same directory as `api_order_with_oauth_v1.yaml`.
* Create a new directory named `api_order_with_oauth_v1_examples` in the same directory as `api_order_with_oauth_v1.yaml`.
* In it, put a file named get_details.json (the name is immaterial) with the following content:
```json
{
Expand Down Expand Up @@ -1239,7 +1239,7 @@ You can generate sample data from a specification as a starting point or scaffol
java -jar specmatic.jar examples employees.yaml
```

In the above case, sample files will be written into the directory named `employees_data`.
In the above case, sample files will be written into the directory named `employees_examples`.

### Sample Project

Expand Down
42 changes: 21 additions & 21 deletions documentation/service_virtualisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Feature: Square API
A useful stub might be that when we post the number 5, we get 25 back.

Follow these steps:
- Create a directory named square_data, in the same directory as the square.spec file.
- Create a directory named square_examples, in the same directory as the square.spec file.
- In that directory, create a json file, name it what you like. For example, square_of_5.json
- Put in that file the following text:

Expand Down Expand Up @@ -149,7 +149,7 @@ The directory structure now looks like this:
```
|
\_ square.spec [file]
\_ square_data [directory]
\_ square_examples [directory]
|
\_ square_of_5.json [file]
\_ square_of_6.json [file]
Expand All @@ -160,12 +160,12 @@ Try running the stub now:
```shell
> {{ site.spec_cmd }} stub square.spec
Reading the stub files below:
./square_data/square_of_5.json
./square_data/square_of_6.json
./square_examples/square_of_5.json
./square_examples/square_of_6.json
Stub server is running on http://localhost:9000. Ctrl + C to stop.
```

Specmatic looks for a directory with the filename of the specmatic file, + the suffix "_data". It found it in this case, and loaded it.
Specmatic looks for a directory with the filename of the specmatic file, + the suffix "_examples". It found it in this case, and loaded it.

In another tab, let's post 5 to the stub and see what happens:

Expand Down Expand Up @@ -207,7 +207,7 @@ Feature: Customer API
Then status 200
```

Create a directory named customer_data, and put this stub in it:
Create a directory named customer_examples, and put this stub in it:

```json
// filename: new_customer.json
Expand All @@ -231,7 +231,7 @@ Run the stub:
```shell
> {{ site.spec_cmd }} stub customer.spec
Reading the stub files below:
/path/to/customer_data/new_customer.json
/path/to/customer_examples/new_customer.json
Stub server is running on http://localhost:9000. Ctrl + C to stop.
```

Expand Down Expand Up @@ -260,7 +260,7 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and put this stub in it:
Create a directory named customer_examples, and put this stub in it:

```json
// filename: new_customer.json
Expand All @@ -285,8 +285,8 @@ Run the stub:
```
> {{ site.spec_cmd }} stub customer.spec
Reading the stub files below:
/path/to/customer_data/new_customer.json
/path/to/customer_data/new_customer.json didn't match customer.spec
/path/to/customer_examples/new_customer.json
/path/to/customer_examples/new_customer.json didn't match customer.spec
In scenario "Add customer"
>> REQUEST.BODY.address
Expand Down Expand Up @@ -325,7 +325,7 @@ Feature: Square API

Create a stub for it:

File: square_data/stub.json
File: square_examples/stub.json
```json
{
"http-request": {
Expand All @@ -345,9 +345,9 @@ Run the stub:
```bash
> specmatic stub square.spec
Loading square.spec
Loading stub expectations from /Users/joelrosario/tmp/square_data
Loading stub expectations from /Users/joelrosario/tmp/square_examples
Reading the following stub files:
/Users/joelrosario/tmp/square_data/stub.json
/Users/joelrosario/tmp/square_examples/stub.json
Stub server is running on http://0.0.0.0:9000. Ctrl + C to stop.
```

Expand Down Expand Up @@ -390,7 +390,7 @@ If you want to stub out multiple contracts together:
> {{ site.spec_cmd }} stub customer.spec order.spec
```

If the customer_data and order_data directories exist, stub data will be loaded from them automatically.
If the customer_examples and order_examples directories exist, stub data will be loaded from them automatically.

### Lenient stubbing

Expand All @@ -408,10 +408,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and inside it a file named stub.json, with the following contents:
Create a directory named customer_examples, and inside it a file named stub.json, with the following contents:

```json
// filename: customer_data/stub.json
// filename: customer_examples/stub.json
{
"http-request": {
"method": "GET",
Expand Down Expand Up @@ -473,10 +473,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and inside it a file named stub.json, with the following contents:
Create a directory named customer_examples, and inside it a file named stub.json, with the following contents:

```json
// filename: customer_data/stub.json
// filename: customer_examples/stub.json
{
"http-request": {
"method": "GET",
Expand Down Expand Up @@ -523,7 +523,7 @@ Feature: Contract for the petstore service

The path parameter id and query parameter name can be setup in the corresponding data json file with below syntax.

File: petstore_data/petstore.json
File: petstore_examples/petstore.json
```json
{
"http-request": {
Expand Down Expand Up @@ -632,10 +632,10 @@ Feature: Customer API
And response-body (string)
```

Create a directory named customer_data, and a file named stub.json within it that contains this:
Create a directory named customer_examples, and a file named stub.json within it that contains this:

```json
// filepath: customer_data/stub.json
// filepath: customer_examples/stub.json
{
"http-request": {
"method": "POST",
Expand Down
10 changes: 5 additions & 5 deletions documentation/service_virtualization_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ paths:
type: string
```
- Create a directory named products-api_data in which we will place these stubs.
- Create a directory named products-api_examples in which we will place these stubs.
## Stub Out The Product Service
Expand All @@ -133,7 +133,7 @@ Specmatic returns a contract valid response. The values are randomly generated.

## Fix The Response To /products/10

* Create a file named expectation.json, inside products-api_data, with the following contents:
* Create a file named expectation.json, inside products-api_examples, with the following contents:

```json
{
Expand Down Expand Up @@ -455,7 +455,7 @@ components:
type: string
```

If you stub it out, right out the gate, with no further `_data` files or any effort, if you send POST /znsio/specmatic/employees with a JSON object `{"name": "Jill Doe", "department": "Engineering", "designation": "Directory"}`, you'll get back `{"id": 10}`. Note how both the request and response exist as examples in the specification, and are being used directly as expectations with no further effort.
If you stub it out, right out the gate, with no further `_examples` files or any effort, if you send POST /znsio/specmatic/employees with a JSON object `{"name": "Jill Doe", "department": "Engineering", "designation": "Directory"}`, you'll get back `{"id": 10}`. Note how both the request and response exist as examples in the specification, and are being used directly as expectations with no further effort.

Note that this currently works only for JSON request and response payloads. Support for other parts such as headers, query parameters, etc will be implemented soon.

Expand Down Expand Up @@ -620,7 +620,7 @@ A regular expression could be added as a constraint to the contract, but it woul

Specmatic allows granular control over simulating a slow response for certain requests.

Let us create another expecation file on the same lines as [expectation.json](/documentation/service_virtualization_tutorial.html#fix-the-response-to-products10) in the products-api_data folder and call it expectation-with-delay.json with below content.
Let us create another expectation file on the same lines as [expectation.json](/documentation/service_virtualization_tutorial.html#fix-the-response-to-products10) in the products-api_examples folder and call it expectation-with-delay.json with below content.

```yaml
{
Expand Down Expand Up @@ -885,7 +885,7 @@ You can generate sample data from a specification as a starting point or scaffol
java -jar specmatic.jar examples employees.yaml
```
In the above case, sample files will be written into the directory named `employees_data`.
In the above case, sample files will be written into the directory named `employees_examples`.
## Sample Java Project
Expand Down
Loading

0 comments on commit 4a40f8b

Please sign in to comment.