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

Skip groovy.lang package in ModelConverters #4594

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public ModelConverters(boolean openapi31) {
}
}

public Set<String> getSkippedPackages() {
return skippedPackages;
}

public static ModelConverters getInstance(boolean openapi31) {
if (openapi31) {
if (SINGLETON31 == null) {
Expand All @@ -58,7 +62,8 @@ public static ModelConverters getInstance(boolean openapi31) {
}

private static void init(ModelConverters converter) {
converter.skippedPackages.add("java.lang");
converter.addPackageToSkip("java.lang");
converter.addPackageToSkip("groovy.lang");

ServiceLoader<ModelConverter> loader = ServiceLoader.load(ModelConverter.class);
Iterator<ModelConverter> itr = loader.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,23 @@ public void indirectPropertiesRecognized() {
assertEquals(model.getProperties().size(), 1);
}

@Test
public void checkDefaultSkippedPackages(){
ModelConverters modelConverters = ModelConverters.getInstance();

assertTrue(modelConverters.getSkippedPackages().contains("java.lang"));
assertTrue(modelConverters.getSkippedPackages().contains("groovy.lang"));
}

@Test(description = "It should not process skipped package")
public void ignoreSkippedPackage() throws ClassNotFoundException {
ModelConverters modelConverters = ModelConverters.getInstance();
final Type type = Class.forName("java.lang.String");
assertNull(modelConverters.readAllAsResolvedSchema(type));


}

@JsonSerialize(as = AnnotatedImplementationClass.class)
abstract class BaseClass {
public abstract String field();
Expand All @@ -406,6 +423,7 @@ public void directPropertiesRecognized() {
assertEquals(model.getProperties().size(), 1);
}


abstract class AnnotatedBaseClass {
@JsonProperty
public abstract String field();
Expand Down
Loading