diff --git a/modules/core/src/main/scala/playground/ServiceNameExtractor.scala b/modules/core/src/main/scala/playground/ServiceNameExtractor.scala index d513e8ad..3ed3f0c3 100644 --- a/modules/core/src/main/scala/playground/ServiceNameExtractor.scala +++ b/modules/core/src/main/scala/playground/ServiceNameExtractor.scala @@ -10,7 +10,15 @@ object ServiceNameExtractor { def fromService[Alg[_[_, _, _, _, _]]]( service: Service[Alg] ): QualifiedIdentifier = QualifiedIdentifier.fromShapeId( - service.id.copy(name = service.hints.get(api.Service).map(_.sdkId).getOrElse(service.id.name)) + service + .id + .copy(name = + service + .hints + .get(api.Service) + .map(_.sdkId.replaceAll("\\s+", "")) + .getOrElse(service.id.name) + ) ) } diff --git a/modules/core/src/test/scala/playground/ServiceNameExtractorTests.scala b/modules/core/src/test/scala/playground/ServiceNameExtractorTests.scala index a1c8b125..4749d192 100644 --- a/modules/core/src/test/scala/playground/ServiceNameExtractorTests.scala +++ b/modules/core/src/test/scala/playground/ServiceNameExtractorTests.scala @@ -1,6 +1,7 @@ package playground import cats.data.NonEmptyList +import demo.fake_aws.MyGoodThing import demo.fake_aws.MyThing import demo.smithy.DemoServiceGen import playground.smithyql.QualifiedIdentifier @@ -15,6 +16,13 @@ object ServiceNameExtractorTests extends FunSuite { ) } + test("extract name of service with an AWS hint and whitespace") { + assert.eql( + ServiceNameExtractor.fromService(MyGoodThing.service), + QualifiedIdentifier(NonEmptyList.of("demo", "fake_aws"), "MyGoodThing"), + ) + } + test("aws hint dynamic") { val dsi = DynamicModel.discover() diff --git a/modules/core/src/test/smithy/fake_aws.smithy b/modules/core/src/test/smithy/fake_aws.smithy index 3f13f908..87994591 100644 --- a/modules/core/src/test/smithy/fake_aws.smithy +++ b/modules/core/src/test/smithy/fake_aws.smithy @@ -10,3 +10,8 @@ service MyAwsService { operation MyAwsOp { } + +@aws.api#service(sdkId: "My Good Thing", endpointPrefix: "mygoodthing") +service MyAwsService2 { + operations: [MyAwsOp] +}