Skip to content

Commit a506e96

Browse files
committed
readme update
1 parent 727da7a commit a506e96

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Major features:
1010
- path parameters, URL paramters and JSON body models are replaced with custom values,
1111
- access swagger.json from URL, which is protected by `basic authentication`,
1212
- control which swagger endpoints are called by specifying `request filters` (check below)
13+
- data generation for missing values (Experimental)
1314

1415
## Sample
1516

@@ -38,6 +39,8 @@ SwaggerUrlSource swaggerSource = new SwaggerUrlSource(
3839
TestTypes = new List<TestType>() { TestType.LoadTest },
3940
EndpointNameWhitelist = new string[] { "GetCategories" }
4041
});
42+
options.AddBaseUrl(new Uri("https://dev.myapi.com"));
43+
options.AddDataGeneration();
4144
});
4245

4346
//To run the Swagger parser we need to pass an array of URLs
@@ -62,6 +65,8 @@ That, does not stop there, you can also populate JSON request bodies in this way
6265

6366
[TODO sample JSON Body]
6467

68+
`ReplcementValue[]` has precedence over data generation (check below chapter 5).
69+
6570
#### 2. AddBasicAuthentication
6671
If your Swagger.json files are protected by basic authentication, you can set those with `AddBasicAuthentication`.
6772

@@ -119,11 +124,28 @@ The same swagger-json excerpt which allows load and integration tests.
119124
##### 3.3 EndpointNameWhitelist
120125
Final `RequestFilter` option is `EndpointNameWhitelist`. With it you can specify a list of endpoints that will be included in the results.
121126

122-
Every other endpoint will be excluded. In the sample above we have set the result to include only `GetCategories` endpoint. That corresponds to the `operationId` in the swagger file above.
127+
Every other endpoint will be excluded. In the sample above we have set the result to include only `GetCategories` endpoint.
128+
That corresponds to the `operationId` in the swagger file above.
129+
130+
#### 4. AddBaseUrl
131+
Your swagger file has a `Server section`, where you can specify an server URI and can be absolute or relative. An example of relative server section is:
132+
```json
133+
"servers": [
134+
{
135+
"url": "/api/v3"
136+
}
137+
],
138+
```
139+
In case of relative paths you need to add an absolute base URL to `Swagger Processor` with `AddBaseUrl`, otherwise the one from the `Servers section` will be used.
140+
141+
#### 5. AddDataGeneration
142+
##### !! EXPERIMENTAL !!
143+
This is an experimental feature. It will generate the missing data in the `List<HttpTestRequest>` object from the swagger models, uri and query parameters.
144+
`ReplcementValue[]` has precedence over data generation.
123145

124146
## TO-DO
125147

126-
- Support for automatic model data generation.
148+
N/A
127149

128150
## License
129151

src/QAToolKit.Source.Swagger/SwaggerFileSource.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public async Task<IList<HttpTestRequest>> Load(IList<FileInfo> source)
3535
{
3636
if (source == null) throw new ArgumentNullException(nameof(source));
3737

38-
if (_swaggerOptions.BaseUrl == null) throw new Exception("Swagger from file source needs BaseUrl defined. If absolute URL is defined in swagger file, that one will be used.");
39-
4038
var restRequests = new List<HttpTestRequest>();
4139
var processor = new SwaggerProcessor();
4240

src/QAToolKit.Source.Swagger/SwaggerProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public IList<HttpTestRequest> MapFromOpenApiDocument(Uri baseUri, OpenApiDocumen
3636
}
3737
else
3838
{
39+
if(baseUri == null)
40+
{
41+
throw new Exception("Swagger from file source needs BaseUrl defined. Inject baseUrl with AddBaseUrl in your SwaggerSource instantiation.");
42+
}
43+
3944
baseUri = new Uri(baseUri, tempUri);
4045
}
4146
}

0 commit comments

Comments
 (0)