This topic explains how to create virtual assets from an OpenAPI/Swagger definition.
Virtualize can automatically create a .pva based on the endpoints found in an OpenAPI/Swagger description. Each .pva will contain Message Responders for all of the defined endpoints. This is especially helpful if the service you want to virtualize is not available for live recording, but you have access to a definition file that describes it.
The following specifications are supported:
Java 7 or newer is required to use this functionality (Java 8 or newer on Mac).
There are two main steps involved in virtualizing the application behavior from a definition file:
To automatically create Message Responders from a OpenAPI/Swagger definition:
Virtualize will then create one Message Responder configured for each resource/method/status code in the OpenAPI/Swagger definition. A sample message (if available) is included in the response. If the service definition includes a schema, that schema is used to construct and constrain the response.
You can use the available controls to specify the response messages. For more details about reviewing and customizing the options in the tools that are created, see Message Responder Overview.
If the .pva is created directly in the VirtualAssets project, it will be deployed automatically. Otherwise, the simplest way to deploy the virtual asset is to copy the containing .pva file into the VirtualAssets project.
Alternatively, you could right-click the Virtualize Server view’s Local machine node, choose Add Virtual Asset, specify the .pva file that includes the virtual assets you want to deploy, then click Finish. When the wizard completes, Virtualize will automatically copy the .pva file to the VirtualAssets project.
For a more detailed discussion of deployment procedures and options, see Deploying Virtual Assets.
For details on how to customize the Message Responder’s behavior, see Message Responder Overview.