Merge branch 'master' into features/sparser-1.0.18
This commit is contained in:
@@ -107,7 +107,7 @@ public class Swagger2MarkupConfigBuilder {
|
||||
Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
|
||||
Swagger2MarkupProperties swagger2MarkupProperties = new Swagger2MarkupProperties(swagger2markupConfiguration);
|
||||
|
||||
config.markupLanguage = swagger2MarkupProperties.getMarkupLanguage("markupLanguage");
|
||||
config.markupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage("markupLanguage");
|
||||
config.generatedExamplesEnabled = swagger2MarkupProperties.getRequiredBoolean("generatedExamplesEnabled");
|
||||
config.operationDescriptionsEnabled = swagger2MarkupProperties.getRequiredBoolean("operationDescriptionsEnabled");
|
||||
config.definitionDescriptionsEnabled = swagger2MarkupProperties.getRequiredBoolean("definitionDescriptionsEnabled");
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.apache.commons.configuration.ConfigurationConverter;
|
||||
import org.apache.commons.configuration.MapConfiguration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -145,12 +147,53 @@ public class Swagger2MarkupProperties {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Path property value associated with the given key, or
|
||||
* {@code defaultValue} if the key cannot be resolved.
|
||||
* @param key the property name to resolve
|
||||
* @throws IllegalStateException if the value cannot be mapped to the enum
|
||||
*/
|
||||
public Optional<Path> getPath(String key){
|
||||
Optional<String> property = getString(key);
|
||||
if(property.isPresent()){
|
||||
return Optional.of(Paths.get(property.get()));
|
||||
}else{
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Path property value associated with the given key (never {@code null}).
|
||||
* @throws IllegalStateException if the key cannot be resolved
|
||||
*/
|
||||
public Path getRequiredPath(String key){
|
||||
Optional<String> property = getString(key);
|
||||
if(property.isPresent()){
|
||||
return Paths.get(property.get());
|
||||
}else{
|
||||
throw new IllegalStateException(String.format("required key [%s] not found", key));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the MarkupLanguage property value associated with the given key, or
|
||||
* {@code defaultValue} if the key cannot be resolved.
|
||||
* @param key the property name to resolve
|
||||
*/
|
||||
public MarkupLanguage getMarkupLanguage(String key){
|
||||
public Optional<MarkupLanguage> getMarkupLanguage(String key){
|
||||
Optional<String> property = getString(key);
|
||||
if(property.isPresent()){
|
||||
return Optional.of(MarkupLanguage.valueOf(property.get()));
|
||||
}else{
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the MarkupLanguage property value associated with the given key (never {@code null}).
|
||||
* @throws IllegalStateException if the key cannot be resolved
|
||||
*/
|
||||
public MarkupLanguage getRequiredMarkupLanguage(String key){
|
||||
return MarkupLanguage.valueOf(configuration.getString(key));
|
||||
}
|
||||
|
||||
|
||||
@@ -794,7 +794,7 @@ public class PathsDocumentBuilder extends MarkupDocumentBuilder {
|
||||
String defaultResolver = super.apply(definitionName);
|
||||
|
||||
if (defaultResolver != null && config.isSeparatedOperationsEnabled())
|
||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File("src/main", defaultResolver).getPath();
|
||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File("..", defaultResolver).getPath();
|
||||
else
|
||||
return defaultResolver;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user