cap-js / openapi

CAP Library for OpenAPI
Apache License 2.0
0 stars 2 forks source link

Invalid API description for unbound functions #55

Open t-bonk opened 1 week ago

t-bonk commented 1 week ago

Hello,

in my CAP Java based service, I have defined the following CDS model:

db/db-model.cds:

entity TestEntity {
    key ID: String;
    name: String;
}

srv/test-service.cds:

using { TestEntity } from '../db/db-model';

service TestService {
  entity TestServiceEntity as projection on TestEntity;

  define type DataEntry {
    ID: String;
    name: String;
  }

  function getEntries(id: String not null, name: String not null) returns array of DataEntry;
}

When generating the openapi.json using this command:

cds compile srv/test-service.cds -2 openapi --openapi:url /odata/v4/TestService > openapi.json

I can see that the generated API description for the unbound function doesn't result in a conformant OData v4 URL. When using Swagger UI the following request URL is generated which is invalid:

http://localhost:8080/odata/v4/TestService/getEntries?id=%27k1%27&name=%27v1%27

The valid OData v4 request URL looks like this:

http://localhost:8080/odata/v4/TestService/getEntries(id=%27k1%27,name=%27v1%27)

This are the versions that are used in my project:

swaggerui-cds
@cap-js/asyncapi 1.0.2
@cap-js/openapi 1.0.5
@sap/cds 8.2.3
@sap/cds-compiler 5.2.0
@sap/cds-dk 8.2.3
@sap/cds-fiori 1.2.7
@sap/cds-foss 5.0.1
@sap/cds-mtxs 2.1.0
@sap/eslint-plugin-cds 3.0.5
CAP Java SDK 3.3.1
Java 21.0.5, home: /Library/Java/JavaVirtualMachines/sapmachine-21.jdk/Contents/Home
Maven 3.9.9, home: /Users/D021624/SAPDevelop/Tools/apache-maven-3.9.9
Node.js v20.17.0
OS Mac OS X, 15.1, arch: aarch64
Spring Boot 3.3.5
cds4j 3.3.1
home /Users/D021624/SAPDevelop/CAPJava/Samples/swaggerui/node_modules/@sap/cds-dk/node_modules/@sap/cds

Can you please fix this issue?

Best regards Thomas

t-bonk commented 18 hours ago

Hello @RoshniNaveenaS,

are there any updates regarding this issue? Since it is related to an incident of an external customer, it is quite urgent.

Tanks & Best regards Thomas

t-bonk commented 18 hours ago

@RoshniNaveenaS BTW I also tested with version 1.0.7 which also has the issue.