Class ScalaCaskServerCodegen.OperationGroup

  • Enclosing class:
    ScalaCaskServerCodegen

    public static class ScalaCaskServerCodegen.OperationGroup
    extends Object
    This data structure is here to manually identify and fix routes which will overlap (e.g. GET /foo/bar and GET /foo/bazz) If we added these as individual routes, then Cask itself will compile, but calling 'initialize' throws a route overlap exception:

    {{{ Routes overlap with wildcards: get /user/logout, get /user/:username, get /user/login }}}

    Note: The same error persists even if the suffixes are unique: {{{ Routes overlap with wildcards: get /user/logout/3, get /user/:username/1, get /user/login/2 }}}

    To fix this, we need to identify and resolve conflicts in our generated code.

    # How do we identify conflicts?

    1. group routes by their non-param prefixes.

    2. add an "x-annotation" vendor extension for operations

    3. add a list of "RouteGroups" which can manually delegate as per below

    # How do we resolve conflicts?

    We leave out the cask route annotation on the conflicting operations, e.g. : {{{ //conflict: @cask.get("/user/:username") def getUserByName(username: String, request: cask.Request) = ... }}}

    and we introduce a new discriminator function to "manually" call those conflicts: {{{

    • Constructor Detail

      • OperationGroup

        public OperationGroup​(String httpMethod,
                              String pathPrefix)
    • Method Detail

      • hasGroupQueryParams

        public boolean hasGroupQueryParams()
      • getGroupQueryParams

        public Collection<CodegenParameter> getGroupQueryParams()
        This is invoked from `scala-cask/apiRoutesQueryParamsTyped.mustache`
        Returns:
        the CodegenParameters
      • updateAnnotations

        public void updateAnnotations()