Skip to content

Commit

Permalink
Picks nonarg constructor of a metadata for docs building
Browse files Browse the repository at this point in the history
fixes gh-1896
  • Loading branch information
marcingrzejszczak committed Apr 26, 2023
1 parent 0767043 commit 7fce11b
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -93,8 +94,16 @@ private StringBuilder adocWithMetadata(List<Class> metadata) throws Exception {
mapper.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);
StringBuilder sb = new StringBuilder();
for (Class metadatum : metadata) {
SpringCloudContractMetadata newInstance = (SpringCloudContractMetadata) metadatum
.getDeclaredConstructors()[0].newInstance();
Constructor constructor = null;
try {
constructor = metadatum.getDeclaredConstructor(null);
}
catch (Exception ex) {
log.warn("Failed to find a no-args constructor for matadatum [" + metadatum + "]", ex);
continue;
}
Object instance = constructor.newInstance();
SpringCloudContractMetadata newInstance = (SpringCloudContractMetadata) instance;
String description = newInstance.description();
String key = newInstance.key();
List<Class> additionalClasses = classesToLookAt(metadatum, newInstance);
Expand Down

0 comments on commit 7fce11b

Please sign in to comment.