Skip to content

Commit

Permalink
AWS: remove whitespace in sdkId lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Sep 2, 2024
1 parent eeba271 commit a802984
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions modules/core/src/test/smithy/fake_aws.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ service MyAwsService {
operation MyAwsOp {

}

@aws.api#service(sdkId: "My Good Thing", endpointPrefix: "mygoodthing")
service MyAwsService2 {
operations: [MyAwsOp]
}

0 comments on commit a802984

Please sign in to comment.