Apicurio / apicurio-data-models

A library (Java and JavaScript compatible) to implement data models for OpenAPI and AsyncAPI.
https://www.apicur.io/datamodels/
Apache License 2.0
55 stars 38 forks source link

fix: add a constructor that accepts AaiMessage to ChangeHeadersRefCommand_Aai20 to fix change of message headers ref in apicurio #803

Closed ben-lc closed 2 months ago

ben-lc commented 2 months ago

Hi, I'm new to apicurio so I will appreciate any advice regarding this PR if I did something wrong.

This PR is related to https://github.com/Apicurio/apicurio-studio/issues/2737

I tried to use ChangePropertyCommand as suggested by deprecated doc in ChangeHeadersRefCommand_Aai20, but since we have to create headers node on the message node if headers is null, it's not possible to use ChangePropertyCommand cause it only works with simple types. I ended up updating ChangeHeadersRefCommand_Aai20 and bringing same modifications that were done to ChangePayloadRefCommand_Aai20 to support a constructor with AaiMessage.

EricWittmann commented 2 months ago

Hi @ben-lc I think this looks good, but it's a nice opportunity to add a test for the use-case you're trying to fix. It should be very easy to do. Have a look at the test framework for commands here:

https://github.com/Apicurio/apicurio-data-models/blob/1.x/src/test/resources/fixtures/cmd/tests.json

You just need to follow the pattern in that file (and obviously the files it points to). :)

wdyt?

ben-lc commented 2 months ago

Hi @EricWittmann, thanks for your feedback, I've added the test for this use case.

EricWittmann commented 2 months ago

👍👍

EricWittmann commented 2 months ago

Merged!