oav/lib/generator
JianyeXi 33a8222912
Example generation improvement (#550)
* add example cache

* improve merge array cache algorithm

* fix comments

* fix snapshot

Co-authored-by: jianye xi <jianyxi@microsoft.com>
2021-01-07 10:52:02 +08:00
..
README.md
exampleCache.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
exampleGenerator.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
exampleRule.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
mocker.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
swaggerMocker.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
translator.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00
util.ts Example generation improvement (#550) 2021-01-07 10:52:02 +08:00

README.md

What does the tool do? What issues does the tool catch?

Example Generator generates swagger examples according to swagger spec file.

Command usage:

oav generate-examples <spec-path>

Params:
  spec-path          the swagger spec file path


Options:
  --payload          Set the payload directory which contains all the payload file, the file format is listed below. If no payload file is provided under the directory, then no examples will be generated. If the option '--payload' is not set, the example values will be mocked for all operations.
  -o                 Specify operationId to generate example only for the operation
  -l, --logLevel     Set the logging level for console.
  [choices: "off", "json", "error", "warn", "info", "verbose", "debug", "silly"]
                                                               [default: "warn"]
  -f, --logFilepath  Set the log file path. It must be an absolute filepath. By
                     default the logs will stored in a timestamp based log file
                     at "C:\Users\abc\oav_output".
  -h, --help         Show help                                         [boolean]

payload file

Payload directory should contains folders named by operationId. Put payload files named by status code under the folder.

.
└── SignalR_Get
    └── 200.json
└── SignalR_CreateOrUpdate
    ├── 201.json
    └── 202.json

Payload file should be a valid json file and contains liveRequest && liveResponse. It can be fetched in live validation result from kusto.


{
    "liveRequest": {
        "headers": {},
        "method": "PUT",
        "url": "",
        "body": {},
        "query": {}
    },
    "liveResponse": {
        "statusCode": "202",
        "headers": {
        },
        "body": {}
    }
}