Set the default service version for OpenAPI documentation

Define which version of a service is shown by default in the OpenAPI documentation.

You can define a default version for an entire web service. The default version determines which versions of the operations appear in the OpenAPI documentation when no specific version is requested.

The default version is set in the service information record using the WSVersion (module) attribute.

This setting applies to the entire web service.

OpenAPI

When a default version is defined for a service, you do not need to specify the version in the query string when requesting the OpenAPI document. For example, the following request returns the OpenAPI documentation for the default version of the service: http://myServer:myPort/gas/ws/r/myGroup/myXcf/myService?openapi.json
Important:

Setting a default version is optional. However, if no default version is defined and the client does not specify a version in the query string, the request returns a 404 (Not found) and the server raises error 41 internally.

The output shown in this example is from the Firefox™ browser, which formats JSON for readability. The appearance may vary depending on your browser.
When choosing a default version for the OpenAPI document, make sure the version represents a complete set of operations for the service. The default version can include:
  • operations whose WSVersion value matches the version name you set at the module level, and
  • operations that are unversioned or use WSVersion="default".
You can also choose a version name that is not used by any operation. In this case, the OpenAPI document only includes operations without WSVersion or with WSVersion="default". This is useful when introducing versioning in the first release of a service; for example, setting WSVersion="v1" even though none of the operations are versioned yet. It helps users understand that versioning is supported and prepares them for future changes.

Default OpenAPI version

In this example, WSVersion is set to "v3". This makes v3 the default version used when generating the OpenAPI documentation for the web service.
Warning:

When you use WSVersion at the module level, you can only assign a single version, and the value cannot be "default". Multiple versions or using WSVersion="default" are only allowed at the function level. If either is detected at the module level, the compiler reports error error-9140.

PUBLIC DEFINE myInfo RECORD ATTRIBUTES(WSInfo, WSVersion = "v3")
   title STRING
   # ...
END RECORD