Version an operation

You specify the version in which the operation will be accessible by setting the WSVersion attribute.

You version an operation if changes to an existing function, such as the request and/or response data, would break existing use of the operation. You need to create a new version of the function to apply the changes. The new version of the function will be offered with the latest release of your REST web service. This will not affect existing users who will continue to use the previous version.

With versioning, you can use the same operation – with the same path and verb – as many times as needed, provided each operation has a different WSVersion version value.

To create a new version of the operation:

  1. Create a copy of the existing function, and paste it in the same file.
  2. Rename the function copy, for example operationId_version_name.
  3. Add the WSVersion attribute to the ATTRIBUTES clause of the function and set the version name.
    For example:
    PUBLIC FUNCTION prices_v2(nb INTEGER ATTRIBUTE(WSParam))
     ATTRIBUTES (WSGet,WSPath="/prices/{nb}",WSVersion="v2") 
     RETURNS (INTEGER)
       DEFINE price integer
       # function code ... 
      RETURN prie 
    END FUNCTION
  4. Code the changes to the function.

To generate the OpenAPI documentation for this version, add &version=version_name to the operation query string, for example http://myhost:6394/gas/ws/r/myGroup/myXcf/myService?openapi.json&version=v2. For information about generating a version of the OpenAPI document, see Generate Open API document based on a version.