WSVersionMode

Defines the method of access when the GWS generates the OpenAPI documentation.

Syntax

WSVersionMode = "{ uri | header | query }"
Where:
  1. WSVersionMode has three options: uri, header, or query. It is a string value setting. It can only contain one value.

WSVersionMode is an optional attribute that is only allowed in the service information record of the module. A WSVersion (module) attribute must also be set , otherwise error 9142 is thrown.

Usage

WSVersion function and module attributes activate versioning mode. In the default versioning mode, the GWS automatically prefixes the version to the operation's resource path in the OpenAPI documentation. This is the uri versioning mode.

For example, if before versioning, the resource path as defined by WSPath was:

/prices/{nb}

After versioning the operation ("v2" in the example), the resource path is:

/v2/prices/{nb}

Access to operations can be changed with the optional attribute WSVersionMode on the service information record. The main purpose of the service information record (defined with the WSInfo attribute) is to document the REST service. If you are not setting the version mode, the record is still needed to provide service information.

You can set the versioning mode to one of the three supported versioning methods; versioning the URI, adding a custom header, or using a query string, depending on your preference. The GWS generates the OpenAPI documentation and creates the functions in the stub file for the version based on the mode. The whole REST Web service will use the same access mode.

To learn about version mode (to include how the GWS handles version mode in the OpenAPI description of operations ), see Specify version mode.

Example using WSVersionMode

In this sample information record the WSVersionMode is set to "query". This means access to operations of the service is made by a parameter adding a query string to the URI, such as /users?api-version=v2. Client applications need to provide a value for the query parameter (api-version) when making a call to the service.
PUBLIC DEFINE serviceInfo RECORD ATTRIBUTES(WSInfo, 
                                           WSScope="users", 
                                           WSVersion="v2" WSVersionMode="query")
  title STRING,
  description STRING,
  termOfService STRING,
  contact RECORD
    name STRING,
    url STRING,
    email STRING
    END RECORD,
    version STRING
  END RECORD = (
    title: "my service", 
    version: "1.0", 
    contact: ( email:"helpdesk@mysite.com") )