Skip to content

Fix --header parameter #236

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

Merged
merged 1 commit into from
May 26, 2021
Merged
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
15 changes: 14 additions & 1 deletion cli/src/main/java/org/openapitools/openapidiff/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import io.swagger.v3.parser.core.models.AuthorizationValue;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
Expand Down Expand Up @@ -153,7 +159,14 @@ public static void main(String... args) {
}
String oldPath = line.getArgList().get(0);
String newPath = line.getArgList().get(1);
ChangedOpenApi result = OpenApiCompare.fromLocations(oldPath, newPath);

List<AuthorizationValue> auths = null;
if (line.hasOption("header")) {
String[] headers = line.getOptionValues("header");
auths = Collections.singletonList(new AuthorizationValue(headers[0], headers[1], "header"));
}

ChangedOpenApi result = OpenApiCompare.fromLocations(oldPath, newPath, auths);
ConsoleRender consoleRender = new ConsoleRender();
if (!logLevel.equals("OFF")) {
System.out.println(consoleRender.render(result));
Expand Down