Skip to content

Commit

Permalink
fix(experimentalIdentityAndAuth): update `DefaultIdentityProviderConf…
Browse files Browse the repository at this point in the history
…ig` to not dedupe
  • Loading branch information
Steven Yuan authored and syall committed Dec 12, 2023
1 parent 3c2fced commit 2764ee8
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

package software.amazon.smithy.typescript.codegen.auth.http.integration;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.model.knowledge.ServiceIndex;
import software.amazon.smithy.model.shapes.ServiceShape;
Expand Down Expand Up @@ -147,30 +145,15 @@ private getIdentityProviderConfigProvider() {
s.getModel(),
s.getSettings());
ServiceIndex serviceIndex = ServiceIndex.of(s.getModel());
Map<ShapeId, HttpAuthScheme> httpAuthSchemes
= AuthUtils.getAllEffectiveNoAuthAwareAuthSchemes(s.getService(), serviceIndex, authIndex);
// TODO(experimentalIdentityAndAuth): figure out a better deduping strategy
Map<String, ConfigField> visitedConfigFields = new HashMap<>();
Map<ShapeId, HttpAuthScheme> httpAuthSchemes =
AuthUtils.getAllEffectiveNoAuthAwareAuthSchemes(s.getService(), serviceIndex, authIndex);
for (HttpAuthScheme scheme : httpAuthSchemes.values()) {
if (scheme == null) {
continue;
}
for (ConfigField configField : scheme.getConfigFields()) {
if (visitedConfigFields.containsKey(configField.name())) {
ConfigField visitedConfigField = visitedConfigFields.get(configField.name());
if (!configField.equals(visitedConfigField)) {
throw new CodegenException("Contradicting `ConfigField` definitions for `"
+ configField.name()
+ "`; existing: "
+ visitedConfigField
+ ", conflict: "
+ configField);
}
} else {
visitedConfigFields.put(configField.name(), configField);
if (configField.type().equals(ConfigField.Type.MAIN)) {
w.write("$S: config.$L,", scheme.getSchemeId().toString(), configField.name());
}
if (configField.type().equals(ConfigField.Type.MAIN)) {
w.write("$S: config.$L,", scheme.getSchemeId().toString(), configField.name());
}
}
}
Expand Down

0 comments on commit 2764ee8

Please sign in to comment.