Skip to content

PATCH instead of PUT : Use of UpdateMethod in @Capabilities.UpdateRestrictions #77

@DewiDuval

Description

@DewiDuval

Hello CAP OpenApi Team,

I have a CAP entity with a media property (as LargeBinary with @Core.MediaType: 'application/pdf').
So I need a POST request then a PUT request.

The service works fine and now I have to create an openAPI documentation for this.
I used cds compile srv --service all -o docs --to openapi as described in capire.

However, instead of having a PUT request displayed in Swagger, I get a PATCH request.

Searching for a solution I came across the annotation UpdateMethod:

@Capabilities.UpdateRestrictions: {
    Updatable: true,
    UpdateMethod: PUT,
}

Set up like above, I get the error (displayed in VSCode editor): "Path does not exist.CDS (annotations)".
If I set it in single quotes, it says: 'String' not allowed here. Expected: 'Capabilities.HttpMethod'CDS (annotations)

I do not know what to enter and did not find a corresponding entry in the capire documentation.
However in module.exports.csdl2openapi function operationUpdate if I update the line 1348 to:

const updateMethod = updateRestrictions.UpdateMethod ? updateRestrictions.UpdateMethod.$Path.toLowerCase() : "patch";

Then I get the expected behavior in Swagger and a PUT request is displayed.

Of course I do not want to mess around in your code and would prefer to know the proper syntax.
Can you support here please?

Best regards - Dewi

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions