Specify version mode

Specify the mode to access operations.

A Web service information record may contain a WSVersionMode attribute to specify how operations are accessed.

This allows you to change the access mode for all operations of the REST Web service. There are three version modes you can choose: uri, header, and query.

In the example, the WSVersionMode is set to "query". This defines the version mode for the whole Web service.

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

Default version mode (URI)

If WSVersionMode is not set or set to "uri", the GWS handles versioning transparently for the client. It adds the version to the resource path. In the generation of the OpenAPI description of the service, the GWS prefixes the version in the resource path. Figure 1 shows the version in the path of a service with one resource. Figure 2 shows the version in the path of a service with many resources.
Figure: Version mode uri ( service with one resource)

OpenAPI JSON description of a service with one resource using uri to set version mode.
Figure: Version mode uri (service with many resources)

OpenAPI JSON description of a service with many resources using uri to set version mode.

Query mode

If WSVersionMode is set to "query" mode, the GWS adds the query parameter "api-version" to the OpenAPI description of operations of the service. The client will need to set the query parameter to the version. The version will be available in the OpenAPI description of the service. It is set by the enum keyword. In calls to the resource, the GWS adds the query string to the URI, for example "?api-version=v3".
Figure: Version mode query

OpenAPI JSON description of a service using a query to set version mode.

Header mode

If WSVersionMode is set to "header", the GWS adds the header parameter "api-version". The client will need to set the header for the version in calls to the resource. The version will be available in the OpenAPI description of the service. It is set by the enum keyword.
Figure: Version mode header

OpenAPI JSON description of a service using a header to set version mode.