cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OpenAPI - Unable to render this definition

pamesty
Explorer
0 Likes
3,734

Greetings.

I was following this documentation to create my API. https://cap.cloud.sap/docs/advanced/openapi

It was working great in my localhost but when I deploy it on my BTP I get an error (both when I'm using a file or when it's generated on-the-fly.

My server configuration looks like this one https://github.com/SAP-samples/cloud-cap-samples/blob/openapi/bookshop/server.js

This is how it looks on my localhost

This is the error I'm getting on the cloud

Maybe it's some kind of bug and it's being hard to find a solution due that this is brand new.

Any help would be appreciate it.

Accepted Solutions (1)

Accepted Solutions (1)

chgeo
Product and Topic Expert
Product and Topic Expert

Hi,

I guess the error in the UI comes from the fact that no OpenAPI definition could be created on the fly on your deployed app. Which is expected, because the exporter, i.e. the `compile.to.api` API, is not available there (only locally when the app is started from @sap/cds-dk). Reason for that is that we need to keep the runtime package @sap/cds small and efficient, and adding such designtime exporters would spoil this.

In an upcoming release we plan to further improve the designtime flow by integrating the on the fly conversion into `cds watch`, but the situation for deployed applications will not change: no converter there.

I recommend to create the OpenAPI files locally and package them up during build, so that they are available for your application on BTP.

Regards,
Christian

pamesty
Explorer
0 Likes

Thanks for answering. I've found a way to resolve the view via file, when I was using this way of redirecting the path (provided in the documentation):

const fileName = resolve(`srv/docs/${service.name}.openapi3.json`)

I was having the same problem, I tried using this way:

const fileName = resolve(__dirname, 'docs/openapi.json')

And it's solved the problem.

I hope this help anybody else and thanks for your help Mr. Christian.

Answers (0)