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

Add example configuration for springdoc-openapi-gradle-plugin #134

Conversation

sam0r040
Copy link
Collaborator

Added an example configuration for springdoc-openapi-gradle-plugin to the springwolf-kafka-example to demonstrate how it can be used.
To test and ensure that the plugin still works for springwolf, I also added:

  • The plugin is executed before the test step
  • A unit test compares the generated file with expected spec that is also used in the other test.

I'm not super happy with the testing part, because there is no way to ignore exception from springdoc-openapi-gradle-plugin. That means that if there is a problem with the application start and the plugin can not get the spec, the build will fail before the tests are executed. If that is not acceptable we can discuss more complex options ie moving this test into its own gradle task that is executed after the tests.

@sam0r040 sam0r040 force-pushed the feature/example_configuration_for_springdoc-openapi-gradle-plugin branch from 09420a9 to 355aee4 Compare January 20, 2023 17:03
Copy link
Member

@timonback timonback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition and straight forward to use

String expectedWithoutServersKafkaUrlPatch = IOUtils.toString(expectedStream, StandardCharsets.UTF_8);
String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", "localhost:29092");

InputStream actualStream = this.getClass().getResourceAsStream("/openapi-generated.json");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Learning for me, the build folder is also scanned for resources

import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class OpenApiGeneratorTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put a comment that this test is linked to the build.gradle configuration and plugin?
Just to make the link more obvious

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to put a comment to explain the connection between the gradle configuration and this test. Does it help?

@sam0r040 sam0r040 force-pushed the feature/example_configuration_for_springdoc-openapi-gradle-plugin branch from 355aee4 to 684d7fa Compare January 23, 2023 17:23
…ngwolf-kafka-example, use springdoc-openapi-gradle-plugin to generate the api spec before test execution and added a test to ensure that the plugin still works for springwolf
@sam0r040 sam0r040 force-pushed the feature/example_configuration_for_springdoc-openapi-gradle-plugin branch from 684d7fa to 1ce489c Compare January 23, 2023 17:25
@stavshamir
Copy link
Member

Good addition @sam0r040 , thanks for reviewing @timonback

@stavshamir stavshamir merged commit 399bf05 into springwolf:master Jan 23, 2023
timonback referenced this pull request in timonback/springwolf-core Aug 7, 2023
i.e. A MapSchema is an object, but doesn't have properties
timonback referenced this pull request in timonback/springwolf-core Aug 7, 2023
i.e. A MapSchema is an object, but doesn't have properties
timonback added a commit that referenced this pull request Aug 18, 2023
* GH-134: fix: Handle NPE in ExampleJsonGenerator

i.e. A MapSchema is an object, but doesn't have properties
Also catch recursions

* fix: Handle unknown schema

* feat: Provide example value for uuid and email
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