Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#395 support info-extensions definition in environment #401

Conversation

tvahrst
Copy link
Contributor

@tvahrst tvahrst commented Oct 13, 2023

This PR contains a little enhancement which allows the definition of extensions (x-...) for the asyncapi-info block in the spring environment (i.e. in application.yml / .properties)

@netlify
Copy link

netlify bot commented Oct 13, 2023

Deploy Preview for springwolf-ui canceled.

Name Link
🔨 Latest commit 8f250fe
🔍 Latest deploy log https://app.netlify.com/sites/springwolf-ui/deploys/652ce3b88122230008d20191

@timonback
Copy link
Member

Thanks @tvahrst for the addition of the extension object in the info docket.

We have two questions:

  1. We see that the extension property is quite generic (Map<String, Object>) and are wondering which use-case you are covering with it. We can imagine a simple Map<String, String> pair, for which we can simplify the type. Alternatively, the nested structure that you used in the PR. If that is required, we would like to see also a test case along with it.
  2. At this point, the extensions are part of the docket. We were looking for changes in the AsyncApi document as well, but haven't found code changes for that. Feel free to adapt one of the example projects, so that the property is also present in the asyncapi.json file.

@tvahrst
Copy link
Contributor Author

tvahrst commented Oct 15, 2023

Hi Timon,
I was inspired by the extension-Type Map<String, Object which is used in the asyncapi classes (Info, Contact etc.). But I agree, changing this to Map<String, String> in the docketconfig-class is the better solution as SpringWolfConfigProperties#ConfigDocket takes all values from the spring environment. I will change this.

The mapping between ConfigDocket#Info and AsyncAPI happens in DefaultAsyncApiDocketService. I added on line to map the extensions (see comment above).

And I extended one of the existing Tests to check, whether an extension defined in the environment will be present in the resulting asyncapi (see comment above)

@tvahrst
Copy link
Contributor Author

tvahrst commented Oct 16, 2023

I tried to extend the ApiIntegrationTest in examples-amqp with x-* extensions (for info, contact and license) in application.properties.

I than realized, that ApiIntegrationTest currently does not check environment properties - the spring boot application defines a custom Docket bean, which has precedence over docket entries in spring-environemnt.

So I duplicated ApiIntegrationTest : One test runs the springboot application with custom docket bean, the second testcase runs springboot application without custom docket bean, reading docket properties from environment.

Because the custom docket bean is configured with additional consumer and producer definitions (which can not be defined via spring environment), the expected results differ from each other. So I had to provide two expected asyncapi.json files.

@sam0r040
Copy link
Collaborator

@tvahrst For me this is ready for merging if you reduced the testing in the amqp example (see my other comment).

@sam0r040
Copy link
Collaborator

@tvahrst Superseeded by #423

Please enable so that we can do rebasing on your PRs in the future:
Screenshot 2023-10-27 at 15 34 18

@sam0r040 sam0r040 closed this Oct 27, 2023
@timonback
Copy link
Member

@tvahrst In case you find time, feel free to write a couple sentences for the documentation -> springwolf/springwolf.github.io#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants