Customising the import
When importing from a Swagger/OpenAPI spec, it’s often useful to be able to control how certain aspects of the generated stubs are produced. WireMock Cloud supports a number of extension attributes that can be added to your spec document for this purpose.Specifying URL path and query parameters
When WireMock Cloud converts a response example to a stub, by default it will generate random values for URL path and query parameters. However, if a response uses the multiple example format, you can specify the exact parameter values you wish to be required by the stub. This can be useful if your test cases or application under test expects specific responses to be available in your mock API. For instance, given the following Open API path element:/people/abc123 and a required query parameter of fields=summary.
The other will have a URL path equal to /people/cba321 and a required query parameter of fields=full.
Any values not specified in this manner will be randomly generated based on the parameter’s schema.
Controlling data generation from schemas
When importing a response with a schema but no examples, WireMock Cloud will randomly generate an example that conforms to the schema. For each schema attribute an attempt will be made to determine the data type, using theformat if present, but if not making a guess based on the field name. For instance,
a string attribute named date_of_birth will result in the generation of an ISO8601 local
date within the past 99 years e.g. 1971-08-02.
However, you can override this behaviour and specify which data generation strategy should be used.
WireMock Cloud uses Faker to generate example data, and
you can specify the specific faker to use by adding an x-faker attribute to your schema element e.g.
name.namename.first_namename.last_namename.name_with_middlename.titlename.prefixname.suffixname.usernameid.alphanumeric_idid.uuiddate_and_time.birthdaydate_and_time.past_date_timedate_and_time.future_date_timeuri.urllorem.wordlorem.sentencelorem.paragraphcurrency.codeaddress.street_addressaddress.secondary_addressaddress.city_nameaddress.stateaddress.postcodecountry.namecountry.code2country.code3phone_number.phone_numberavatar.image
note Only required query parameters will be included in the stubs’ request criteria. Non-required query parameters will excluded, meaning that any or no value will be accepted.