Skip to content

Commit

Permalink
Don't throw errors for unrecognised traits ouside of smithy.api and a…
Browse files Browse the repository at this point in the history
…ws.api namespaces
  • Loading branch information
adam-fowler committed Apr 15, 2024
1 parent bbcb93f commit 9d90291
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/SotoSmithy/Traits/CustomTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ public struct CustomTrait: Trait {

public func validate(using model: Model, shape: Shape) throws {
guard let traitShape = model.shape(for: self.shapeId) else {
throw Smithy.ValidationError(reason: "Trait \(self.traitName) applied to shape ** does not exist")
// Only throw error is trait is unrecognised and is in the "smithy.api" or "aws.api" namespaces
if self.traitName.namespace == "smithy.api" || self.traitName.namespace == "aws.api" {
throw Smithy.ValidationError(reason: "Trait \(self.traitName) applied to shape ** does not exist")
} else {
return
}
}
guard self.selector.select(using: model, shape: shape) else {
throw Smithy.ValidationError(reason: "Trait \(self.traitName) cannot be applied to shape **")
Expand Down

0 comments on commit 9d90291

Please sign in to comment.