Skip to content

Commit

Permalink
use default root path
Browse files Browse the repository at this point in the history
Signed-off-by: Bartosz Michalik <[email protected]>
  • Loading branch information
bartoszm committed Nov 26, 2021
1 parent 04de926 commit 673fc7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<groupId>com.amartus.sonata</groupId>
<artifactId>blender</artifactId>
<description>SonataBlendingTool</description>
<version>1.6-SNAPSHOT</version>
<version>1.6</version>
<properties>
<!-- <openapi.generator.version>4.3.1</openapi.generator.version>-->
<openapi.generator.version>5.3.0</openapi.generator.version>
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/com/amartus/sonata/blender/cmd/AbstractCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract class AbstractCmd {
name = {"-d", "--spec-root-dir"},
title = "root directory for specificatins to be blended",
description = "sets of product specification root directory for specifications you would like to integrate")
protected String productsRootDir = null;
protected String productsRootDir = ".";

@Option(name = {"-i", "--input-spec"}, title = "spec file",
description = "location of the OpenAPI spec, as URL or file (required)")
Expand Down Expand Up @@ -99,16 +99,19 @@ protected Map<String, Schema> toProductSpecifications() {
}

protected Stream<Pair<Path, String>> toSchemaPaths(Stream<String> path) {
if (productsRootDir == null) {
return path
.map(this::pathWithFragment)
.map(p -> Pair.of(Path.of(p.first()), p.second()));
}

final var rootPath = Path.of(productsRootDir);
final var rootPath = Path.of(productsRootDir).toAbsolutePath();
return path
.map(this::pathWithFragment)
.map(p -> Pair.of(rootPath.resolve(p.first()), p.second()));
.map(p -> Pair.of(toPath(p.first(), rootPath), p.second()));
}

private Path toPath(String path, Path root) {
var p = Path.of(path);
if (p.isAbsolute()) {
return p;
}
return root.resolve(p);
}

protected Pair<String, String> pathWithFragment(String path) {
Expand Down

0 comments on commit 673fc7a

Please sign in to comment.