Skip to content

Commit

Permalink
Reproduce #1594
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Sep 26, 2024
1 parent b828a13 commit d78918b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package smithy4s.example

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.struct

final case class HasConstrainedNewtype(s: CityId)

object HasConstrainedNewtype extends ShapeTag.Companion[HasConstrainedNewtype] {
val id: ShapeId = ShapeId("smithy4s.example", "HasConstrainedNewtype")

val hints: Hints = Hints.empty

// constructor using the original order from the spec
private def make(s: CityId): HasConstrainedNewtype = HasConstrainedNewtype(s)

implicit val schema: Schema[HasConstrainedNewtype] = struct(
CityId.schema.validated(smithy.api.Length(min = Some(1L), max = None)).required[HasConstrainedNewtype]("s", _.s),
)(make).withId(id).addHints(hints)
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private[codegen] object ModelLoader {
val modelsInJars = deps.flatMap { file =>
Using.resource(
// Note: On JDK13+, the second parameter is redundant.
FileSystems.newFileSystem(file.toPath(), null)
FileSystems.newFileSystem(file.toPath(), null: ClassLoader)
) { jarFS =>
val p = jarFS.getPath("META-INF", "smithy", "manifest")

Expand Down
6 changes: 6 additions & 0 deletions sampleSpecs/memberConstraints.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ map ConstrainedMap {
value: String
}

// Regression test for https://github.com/disneystreaming/smithy4s/issues/1594
structure HasConstrainedNewtype {
@length(min: 1)
@required
s: CityId
}

0 comments on commit d78918b

Please sign in to comment.