on ‎2021 Mar 22 6:16 PM
Hello,
I am currently running
cds compile srv --service all -o docs --to openapi
to get the openApi JSON files. I visualize the generated JSON files, using Swagger ( https://editor.swagger.io/)
When I look at the Open Api JSON files on Swagger, the autogenerated ID property of our models are marked as mandatory for the request body in POST requests. The ID field should not be provided, as the IDs are generated automatically in the backend.
The openapi.json file is used by the UI team to generate their JavaScript client code, so our goal is to make sure that the above command generates a file that accurately reflects our API, meaning that the ID field in the request body of POST requests should not be marked as required.
I ran the same process using a Sample CAP Java project and I noticed the same issue.
Here is a sample entity. Notice it is using cuid so ID is autogenerated so it is not required in the input:

Here is the schema the Open Api JSON file created. Notice that the ID is marked as mandatory/required:

Any suggestions, or is this an issue that cannot be fixed?
Request clarification before answering.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.