Skip to content

[BUG] OpenAPI compiler changes the value of @protocol annotation for CDS services #186

Description

@mlakov

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the function _servicePath in ib/compile/index.js#L201 the value of the @protocol annotation of the given CDS service gets changed and is never restored to its original value. This means that using the OpenAPI compiler has unwanted side effects that change (and potentially break) CDS services for the entire runtime of an application.

Expected Behavior

Using the OpenAPI compiler does not result in unwanted / unexpected side effects.

Anything else?

Proposal for a fix:

function _servicePath(csdl, csn, protocols) {
  if (csdl.$EntityContainer && Array.isArray(protocols)) {
    const serviceName = csdl.$EntityContainer.replace(/\.[^.]+$/, "");

    return Object.fromEntries(
      protocols
        .map(protocol => { ...csn.definitions[serviceName], "@protocol: protocol })
        .map(service => [ service["@protocol"], cds.service.path4?.(service) || cds.serve.path4(service)])
    );
  }

  return {}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions