diff --git a/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala b/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala index d7342d070..35e8b0438 100644 --- a/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala +++ b/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala @@ -164,17 +164,19 @@ object DynamoDBOperation { } sealed trait ListTablesError extends scala.Product with scala.Serializable { @inline final def widen: ListTablesError = this - def _ordinal: Int + def $ordinal: Int } object ListTablesError extends ShapeTag.Companion[ListTablesError] { + + def internalServerError(internalServerError:InternalServerError): ListTablesError = InternalServerErrorCase(internalServerError) + def invalidEndpointException(invalidEndpointException:InvalidEndpointException): ListTablesError = InvalidEndpointExceptionCase(invalidEndpointException) + val id: ShapeId = ShapeId("com.amazonaws.dynamodb", "ListTablesError") val hints: Hints = Hints.empty - final case class InternalServerErrorCase(internalServerError: InternalServerError) extends ListTablesError { final def _ordinal: Int = 0 } - def internalServerError(internalServerError:InternalServerError): ListTablesError = InternalServerErrorCase(internalServerError) - final case class InvalidEndpointExceptionCase(invalidEndpointException: InvalidEndpointException) extends ListTablesError { final def _ordinal: Int = 1 } - def invalidEndpointException(invalidEndpointException:InvalidEndpointException): ListTablesError = InvalidEndpointExceptionCase(invalidEndpointException) + final case class InternalServerErrorCase(internalServerError: InternalServerError) extends ListTablesError { final def $ordinal: Int = 0 } + final case class InvalidEndpointExceptionCase(invalidEndpointException: InvalidEndpointException) extends ListTablesError { final def $ordinal: Int = 1 } object InternalServerErrorCase { val hints: Hints = Hints.empty @@ -191,7 +193,7 @@ object DynamoDBOperation { InternalServerErrorCase.alt, InvalidEndpointExceptionCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked.scala b/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked.scala index 2174f084e..ed52db722 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked.scala @@ -10,17 +10,19 @@ import smithy4s.schema.Schema.union sealed trait CheckedOrUnchecked extends scala.Product with scala.Serializable { @inline final def widen: CheckedOrUnchecked = this - def _ordinal: Int + def $ordinal: Int } object CheckedOrUnchecked extends ShapeTag.Companion[CheckedOrUnchecked] { + + def checked(checked:String): CheckedOrUnchecked = CheckedCase(checked) + def raw(raw:String): CheckedOrUnchecked = RawCase(raw) + val id: ShapeId = ShapeId("smithy4s.example", "CheckedOrUnchecked") val hints: Hints = Hints.empty - final case class CheckedCase(checked: String) extends CheckedOrUnchecked { final def _ordinal: Int = 0 } - def checked(checked:String): CheckedOrUnchecked = CheckedCase(checked) - final case class RawCase(raw: String) extends CheckedOrUnchecked { final def _ordinal: Int = 1 } - def raw(raw:String): CheckedOrUnchecked = RawCase(raw) + final case class CheckedCase(checked: String) extends CheckedOrUnchecked { final def $ordinal: Int = 0 } + final case class RawCase(raw: String) extends CheckedOrUnchecked { final def $ordinal: Int = 1 } object CheckedCase { val hints: Hints = Hints.empty @@ -37,6 +39,6 @@ object CheckedOrUnchecked extends ShapeTag.Companion[CheckedOrUnchecked] { CheckedCase.alt, RawCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked2.scala b/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked2.scala index b701bfc2a..358df77af 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked2.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/CheckedOrUnchecked2.scala @@ -10,19 +10,21 @@ import smithy4s.schema.Schema.union sealed trait CheckedOrUnchecked2 extends scala.Product with scala.Serializable { @inline final def widen: CheckedOrUnchecked2 = this - def _ordinal: Int + def $ordinal: Int } object CheckedOrUnchecked2 extends ShapeTag.Companion[CheckedOrUnchecked2] { + + def checked(checked:String): CheckedOrUnchecked2 = CheckedCase(checked) + def raw(raw:String): CheckedOrUnchecked2 = RawCase(raw) + val id: ShapeId = ShapeId("smithy4s.example", "CheckedOrUnchecked2") val hints: Hints = Hints( alloy.Untagged(), ) - final case class CheckedCase(checked: String) extends CheckedOrUnchecked2 { final def _ordinal: Int = 0 } - def checked(checked:String): CheckedOrUnchecked2 = CheckedCase(checked) - final case class RawCase(raw: String) extends CheckedOrUnchecked2 { final def _ordinal: Int = 1 } - def raw(raw:String): CheckedOrUnchecked2 = RawCase(raw) + final case class CheckedCase(checked: String) extends CheckedOrUnchecked2 { final def $ordinal: Int = 0 } + final case class RawCase(raw: String) extends CheckedOrUnchecked2 { final def $ordinal: Int = 1 } object CheckedCase { val hints: Hints = Hints.empty @@ -39,6 +41,6 @@ object CheckedOrUnchecked2 extends ShapeTag.Companion[CheckedOrUnchecked2] { CheckedCase.alt, RawCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedUnion.scala b/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedUnion.scala index f0296c126..32e70dda1 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedUnion.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedUnion.scala @@ -12,9 +12,17 @@ import smithy4s.schema.Schema.union @deprecated(message = "A compelling reason", since = "0.0.1") sealed trait DeprecatedUnion extends scala.Product with scala.Serializable { @inline final def widen: DeprecatedUnion = this - def _ordinal: Int + def $ordinal: Int } object DeprecatedUnion extends ShapeTag.Companion[DeprecatedUnion] { + + @deprecated(message = "N/A", since = "N/A") + def s(s:String): DeprecatedUnion = SCase(s) + def s_V2(s_V2:String): DeprecatedUnion = S_V2Case(s_V2) + def deprecatedUnionProductCase():DeprecatedUnionProductCase = DeprecatedUnionProductCase() + @deprecated(message = "N/A", since = "N/A") + def unionProductCaseDeprecatedAtCallSite():UnionProductCaseDeprecatedAtCallSite = UnionProductCaseDeprecatedAtCallSite() + val id: ShapeId = ShapeId("smithy4s.example", "DeprecatedUnion") val hints: Hints = Hints( @@ -22,13 +30,11 @@ object DeprecatedUnion extends ShapeTag.Companion[DeprecatedUnion] { ) @deprecated(message = "N/A", since = "N/A") - final case class SCase(s: String) extends DeprecatedUnion { final def _ordinal: Int = 0 } - def s(s:String): DeprecatedUnion = SCase(s) - final case class S_V2Case(s_V2: String) extends DeprecatedUnion { final def _ordinal: Int = 1 } - def s_V2(s_V2:String): DeprecatedUnion = S_V2Case(s_V2) + final case class SCase(s: String) extends DeprecatedUnion { final def $ordinal: Int = 0 } + final case class S_V2Case(s_V2: String) extends DeprecatedUnion { final def $ordinal: Int = 1 } @deprecated(message = "N/A", since = "N/A") final case class DeprecatedUnionProductCase() extends DeprecatedUnion { - def _ordinal: Int = 2 + def $ordinal: Int = 2 } object DeprecatedUnionProductCase extends ShapeTag.Companion[DeprecatedUnionProductCase] { val id: ShapeId = ShapeId("smithy4s.example", "DeprecatedUnionProductCase") @@ -43,7 +49,7 @@ object DeprecatedUnion extends ShapeTag.Companion[DeprecatedUnion] { } @deprecated(message = "N/A", since = "N/A") final case class UnionProductCaseDeprecatedAtCallSite() extends DeprecatedUnion { - def _ordinal: Int = 3 + def $ordinal: Int = 3 } object UnionProductCaseDeprecatedAtCallSite extends ShapeTag.Companion[UnionProductCaseDeprecatedAtCallSite] { val id: ShapeId = ShapeId("smithy4s.example", "UnionProductCaseDeprecatedAtCallSite") @@ -76,6 +82,6 @@ object DeprecatedUnion extends ShapeTag.Companion[DeprecatedUnion] { DeprecatedUnionProductCase.alt, UnionProductCaseDeprecatedAtCallSite.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala index f570437a8..f8a80540d 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala @@ -105,22 +105,24 @@ object ErrorHandlingServiceOperation { } sealed trait ErrorHandlingOperationError extends scala.Product with scala.Serializable { @inline final def widen: ErrorHandlingOperationError = this - def _ordinal: Int + def $ordinal: Int } object ErrorHandlingOperationError extends ShapeTag.Companion[ErrorHandlingOperationError] { - val id: ShapeId = ShapeId("smithy4s.example", "ErrorHandlingOperationError") - - val hints: Hints = Hints.empty - final case class EHFallbackClientErrorCase(eHFallbackClientError: EHFallbackClientError) extends ErrorHandlingOperationError { final def _ordinal: Int = 0 } def eHFallbackClientError(eHFallbackClientError:EHFallbackClientError): ErrorHandlingOperationError = EHFallbackClientErrorCase(eHFallbackClientError) - final case class EHServiceUnavailableCase(eHServiceUnavailable: EHServiceUnavailable) extends ErrorHandlingOperationError { final def _ordinal: Int = 1 } def eHServiceUnavailable(eHServiceUnavailable:EHServiceUnavailable): ErrorHandlingOperationError = EHServiceUnavailableCase(eHServiceUnavailable) - final case class EHNotFoundCase(eHNotFound: EHNotFound) extends ErrorHandlingOperationError { final def _ordinal: Int = 2 } def eHNotFound(eHNotFound:EHNotFound): ErrorHandlingOperationError = EHNotFoundCase(eHNotFound) - final case class EHFallbackServerErrorCase(eHFallbackServerError: EHFallbackServerError) extends ErrorHandlingOperationError { final def _ordinal: Int = 3 } def eHFallbackServerError(eHFallbackServerError:EHFallbackServerError): ErrorHandlingOperationError = EHFallbackServerErrorCase(eHFallbackServerError) + val id: ShapeId = ShapeId("smithy4s.example", "ErrorHandlingOperationError") + + val hints: Hints = Hints.empty + + final case class EHFallbackClientErrorCase(eHFallbackClientError: EHFallbackClientError) extends ErrorHandlingOperationError { final def $ordinal: Int = 0 } + final case class EHServiceUnavailableCase(eHServiceUnavailable: EHServiceUnavailable) extends ErrorHandlingOperationError { final def $ordinal: Int = 1 } + final case class EHNotFoundCase(eHNotFound: EHNotFound) extends ErrorHandlingOperationError { final def $ordinal: Int = 2 } + final case class EHFallbackServerErrorCase(eHFallbackServerError: EHFallbackServerError) extends ErrorHandlingOperationError { final def $ordinal: Int = 3 } + object EHFallbackClientErrorCase { val hints: Hints = Hints.empty val schema: Schema[EHFallbackClientErrorCase] = bijection(EHFallbackClientError.schema.addHints(hints), EHFallbackClientErrorCase(_), _.eHFallbackClientError) @@ -148,7 +150,7 @@ object ErrorHandlingServiceOperation { EHNotFoundCase.alt, EHFallbackServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala index f0fd8c73f..70e1643ba 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala @@ -106,22 +106,24 @@ object ErrorHandlingServiceExtraErrorsOperation { } sealed trait ExtraErrorOperationError extends scala.Product with scala.Serializable { @inline final def widen: ExtraErrorOperationError = this - def _ordinal: Int + def $ordinal: Int } object ExtraErrorOperationError extends ShapeTag.Companion[ExtraErrorOperationError] { - val id: ShapeId = ShapeId("smithy4s.example", "ExtraErrorOperationError") - - val hints: Hints = Hints.empty - final case class RandomOtherClientErrorCase(randomOtherClientError: RandomOtherClientError) extends ExtraErrorOperationError { final def _ordinal: Int = 0 } def randomOtherClientError(randomOtherClientError:RandomOtherClientError): ExtraErrorOperationError = RandomOtherClientErrorCase(randomOtherClientError) - final case class RandomOtherServerErrorCase(randomOtherServerError: RandomOtherServerError) extends ExtraErrorOperationError { final def _ordinal: Int = 1 } def randomOtherServerError(randomOtherServerError:RandomOtherServerError): ExtraErrorOperationError = RandomOtherServerErrorCase(randomOtherServerError) - final case class RandomOtherClientErrorWithCodeCase(randomOtherClientErrorWithCode: RandomOtherClientErrorWithCode) extends ExtraErrorOperationError { final def _ordinal: Int = 2 } def randomOtherClientErrorWithCode(randomOtherClientErrorWithCode:RandomOtherClientErrorWithCode): ExtraErrorOperationError = RandomOtherClientErrorWithCodeCase(randomOtherClientErrorWithCode) - final case class RandomOtherServerErrorWithCodeCase(randomOtherServerErrorWithCode: RandomOtherServerErrorWithCode) extends ExtraErrorOperationError { final def _ordinal: Int = 3 } def randomOtherServerErrorWithCode(randomOtherServerErrorWithCode:RandomOtherServerErrorWithCode): ExtraErrorOperationError = RandomOtherServerErrorWithCodeCase(randomOtherServerErrorWithCode) + val id: ShapeId = ShapeId("smithy4s.example", "ExtraErrorOperationError") + + val hints: Hints = Hints.empty + + final case class RandomOtherClientErrorCase(randomOtherClientError: RandomOtherClientError) extends ExtraErrorOperationError { final def $ordinal: Int = 0 } + final case class RandomOtherServerErrorCase(randomOtherServerError: RandomOtherServerError) extends ExtraErrorOperationError { final def $ordinal: Int = 1 } + final case class RandomOtherClientErrorWithCodeCase(randomOtherClientErrorWithCode: RandomOtherClientErrorWithCode) extends ExtraErrorOperationError { final def $ordinal: Int = 2 } + final case class RandomOtherServerErrorWithCodeCase(randomOtherServerErrorWithCode: RandomOtherServerErrorWithCode) extends ExtraErrorOperationError { final def $ordinal: Int = 3 } + object RandomOtherClientErrorCase { val hints: Hints = Hints.empty val schema: Schema[RandomOtherClientErrorCase] = bijection(RandomOtherClientError.schema.addHints(hints), RandomOtherClientErrorCase(_), _.randomOtherClientError) @@ -149,7 +151,7 @@ object ErrorHandlingServiceExtraErrorsOperation { RandomOtherClientErrorWithCodeCase.alt, RandomOtherServerErrorWithCodeCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Foo.scala b/modules/bootstrapped/src/generated/smithy4s/example/Foo.scala index 7f3a5ffae..95c5c4bc4 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Foo.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Foo.scala @@ -16,26 +16,31 @@ import smithy4s.schema.Schema.union */ sealed trait Foo extends scala.Product with scala.Serializable { @inline final def widen: Foo = this - def _ordinal: Int + def $ordinal: Int } object Foo extends ShapeTag.Companion[Foo] { + + def int(int:Int): Foo = IntCase(int) + /** this is a comment saying you should be careful for this case + * you never know what lies ahead with Strings like this + */ + def str(str:String): Foo = StrCase(str) + def bInt(bInt:BigInt): Foo = BIntCase(bInt) + def bDec(bDec:BigDecimal): Foo = BDecCase(bDec) + val id: ShapeId = ShapeId("smithy4s.example", "Foo") val hints: Hints = Hints( smithy.api.Documentation("Helpful information for Foo\nint, bigInt and bDec are useful number constructs\nThe string case is there because."), ) - final case class IntCase(int: Int) extends Foo { final def _ordinal: Int = 0 } - def int(int:Int): Foo = IntCase(int) + final case class IntCase(int: Int) extends Foo { final def $ordinal: Int = 0 } /** this is a comment saying you should be careful for this case * you never know what lies ahead with Strings like this */ - final case class StrCase(str: String) extends Foo { final def _ordinal: Int = 1 } - def str(str:String): Foo = StrCase(str) - final case class BIntCase(bInt: BigInt) extends Foo { final def _ordinal: Int = 2 } - def bInt(bInt:BigInt): Foo = BIntCase(bInt) - final case class BDecCase(bDec: BigDecimal) extends Foo { final def _ordinal: Int = 3 } - def bDec(bDec:BigDecimal): Foo = BDecCase(bDec) + final case class StrCase(str: String) extends Foo { final def $ordinal: Int = 1 } + final case class BIntCase(bInt: BigInt) extends Foo { final def $ordinal: Int = 2 } + final case class BDecCase(bDec: BigDecimal) extends Foo { final def $ordinal: Int = 3 } object IntCase { val hints: Hints = Hints.empty @@ -66,6 +71,6 @@ object Foo extends ShapeTag.Companion[Foo] { BIntCase.alt, BDecCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Food.scala b/modules/bootstrapped/src/generated/smithy4s/example/Food.scala index b1a8d97c2..6dcf7ffce 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Food.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Food.scala @@ -9,17 +9,19 @@ import smithy4s.schema.Schema.union sealed trait Food extends scala.Product with scala.Serializable { @inline final def widen: Food = this - def _ordinal: Int + def $ordinal: Int } object Food extends ShapeTag.Companion[Food] { + + def pizza(pizza:Pizza): Food = PizzaCase(pizza) + def salad(salad:Salad): Food = SaladCase(salad) + val id: ShapeId = ShapeId("smithy4s.example", "Food") val hints: Hints = Hints.empty - final case class PizzaCase(pizza: Pizza) extends Food { final def _ordinal: Int = 0 } - def pizza(pizza:Pizza): Food = PizzaCase(pizza) - final case class SaladCase(salad: Salad) extends Food { final def _ordinal: Int = 1 } - def salad(salad:Salad): Food = SaladCase(salad) + final case class PizzaCase(pizza: Pizza) extends Food { final def $ordinal: Int = 0 } + final case class SaladCase(salad: Salad) extends Food { final def $ordinal: Int = 1 } object PizzaCase { val hints: Hints = Hints.empty @@ -36,6 +38,6 @@ object Food extends ShapeTag.Companion[Food] { PizzaCase.alt, SaladCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ForecastResult.scala b/modules/bootstrapped/src/generated/smithy4s/example/ForecastResult.scala index a6a698cd9..9baebc1e3 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ForecastResult.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ForecastResult.scala @@ -10,9 +10,13 @@ import smithy4s.schema.Schema.union sealed trait ForecastResult extends scala.Product with scala.Serializable { @inline final def widen: ForecastResult = this - def _ordinal: Int + def $ordinal: Int } object ForecastResult extends ShapeTag.Companion[ForecastResult] { + + def rain(rain:ChanceOfRain): ForecastResult = RainCase(rain) + def sun(sun:UVIndex): ForecastResult = SunCase(sun) + val id: ShapeId = ShapeId("smithy4s.example", "ForecastResult") val hints: Hints = Hints.empty @@ -22,10 +26,8 @@ object ForecastResult extends ShapeTag.Companion[ForecastResult] { val sun: Prism[ForecastResult, UVIndex] = Prism.partial[ForecastResult, UVIndex]{ case SunCase(t) => t }(SunCase.apply) } - final case class RainCase(rain: ChanceOfRain) extends ForecastResult { final def _ordinal: Int = 0 } - def rain(rain:ChanceOfRain): ForecastResult = RainCase(rain) - final case class SunCase(sun: UVIndex) extends ForecastResult { final def _ordinal: Int = 1 } - def sun(sun:UVIndex): ForecastResult = SunCase(sun) + final case class RainCase(rain: ChanceOfRain) extends ForecastResult { final def $ordinal: Int = 0 } + final case class SunCase(sun: UVIndex) extends ForecastResult { final def $ordinal: Int = 1 } object RainCase { val hints: Hints = Hints.empty @@ -42,6 +44,6 @@ object ForecastResult extends ShapeTag.Companion[ForecastResult] { RainCase.alt, SunCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala b/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala index 510fced07..394f42c8c 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala @@ -114,17 +114,19 @@ object KVStoreOperation { } sealed trait GetError extends scala.Product with scala.Serializable { @inline final def widen: GetError = this - def _ordinal: Int + def $ordinal: Int } object GetError extends ShapeTag.Companion[GetError] { + + def unauthorizedError(unauthorizedError:UnauthorizedError): GetError = UnauthorizedErrorCase(unauthorizedError) + def keyNotFoundError(keyNotFoundError:KeyNotFoundError): GetError = KeyNotFoundErrorCase(keyNotFoundError) + val id: ShapeId = ShapeId("smithy4s.example", "GetError") val hints: Hints = Hints.empty - final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends GetError { final def _ordinal: Int = 0 } - def unauthorizedError(unauthorizedError:UnauthorizedError): GetError = UnauthorizedErrorCase(unauthorizedError) - final case class KeyNotFoundErrorCase(keyNotFoundError: KeyNotFoundError) extends GetError { final def _ordinal: Int = 1 } - def keyNotFoundError(keyNotFoundError:KeyNotFoundError): GetError = KeyNotFoundErrorCase(keyNotFoundError) + final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends GetError { final def $ordinal: Int = 0 } + final case class KeyNotFoundErrorCase(keyNotFoundError: KeyNotFoundError) extends GetError { final def $ordinal: Int = 1 } object UnauthorizedErrorCase { val hints: Hints = Hints.empty @@ -141,7 +143,7 @@ object KVStoreOperation { UnauthorizedErrorCase.alt, KeyNotFoundErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Put(input: KeyValue) extends KVStoreOperation[KeyValue, KVStoreOperation.PutError, Unit, Nothing, Nothing] { @@ -169,15 +171,17 @@ object KVStoreOperation { } sealed trait PutError extends scala.Product with scala.Serializable { @inline final def widen: PutError = this - def _ordinal: Int + def $ordinal: Int } object PutError extends ShapeTag.Companion[PutError] { + + def unauthorizedError(unauthorizedError:UnauthorizedError): PutError = UnauthorizedErrorCase(unauthorizedError) + val id: ShapeId = ShapeId("smithy4s.example", "PutError") val hints: Hints = Hints.empty - final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends PutError { final def _ordinal: Int = 0 } - def unauthorizedError(unauthorizedError:UnauthorizedError): PutError = UnauthorizedErrorCase(unauthorizedError) + final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends PutError { final def $ordinal: Int = 0 } object UnauthorizedErrorCase { val hints: Hints = Hints.empty @@ -188,7 +192,7 @@ object KVStoreOperation { implicit val schema: UnionSchema[PutError] = union( UnauthorizedErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Delete(input: Key) extends KVStoreOperation[Key, KVStoreOperation.DeleteError, Unit, Nothing, Nothing] { @@ -218,17 +222,19 @@ object KVStoreOperation { } sealed trait DeleteError extends scala.Product with scala.Serializable { @inline final def widen: DeleteError = this - def _ordinal: Int + def $ordinal: Int } object DeleteError extends ShapeTag.Companion[DeleteError] { + + def unauthorizedError(unauthorizedError:UnauthorizedError): DeleteError = UnauthorizedErrorCase(unauthorizedError) + def keyNotFoundError(keyNotFoundError:KeyNotFoundError): DeleteError = KeyNotFoundErrorCase(keyNotFoundError) + val id: ShapeId = ShapeId("smithy4s.example", "DeleteError") val hints: Hints = Hints.empty - final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends DeleteError { final def _ordinal: Int = 0 } - def unauthorizedError(unauthorizedError:UnauthorizedError): DeleteError = UnauthorizedErrorCase(unauthorizedError) - final case class KeyNotFoundErrorCase(keyNotFoundError: KeyNotFoundError) extends DeleteError { final def _ordinal: Int = 1 } - def keyNotFoundError(keyNotFoundError:KeyNotFoundError): DeleteError = KeyNotFoundErrorCase(keyNotFoundError) + final case class UnauthorizedErrorCase(unauthorizedError: UnauthorizedError) extends DeleteError { final def $ordinal: Int = 0 } + final case class KeyNotFoundErrorCase(keyNotFoundError: KeyNotFoundError) extends DeleteError { final def $ordinal: Int = 1 } object UnauthorizedErrorCase { val hints: Hints = Hints.empty @@ -245,7 +251,7 @@ object KVStoreOperation { UnauthorizedErrorCase.alt, KeyNotFoundErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala b/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala index 99dd07edc..02f83e08c 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala @@ -104,15 +104,17 @@ object NameCollisionOperation { } sealed trait MyOpError extends scala.Product with scala.Serializable { @inline final def widen: MyOpError = this - def _ordinal: Int + def $ordinal: Int } object MyOpError extends ShapeTag.Companion[MyOpError] { + + def myOpError(myOpError:smithy4s.example.MyOpError): MyOpError = MyOpErrorCase(myOpError) + val id: ShapeId = ShapeId("smithy4s.example", "MyOpError") val hints: Hints = Hints.empty - final case class MyOpErrorCase(myOpError: smithy4s.example.MyOpError) extends MyOpError { final def _ordinal: Int = 0 } - def myOpError(myOpError:smithy4s.example.MyOpError): MyOpError = MyOpErrorCase(myOpError) + final case class MyOpErrorCase(myOpError: smithy4s.example.MyOpError) extends MyOpError { final def $ordinal: Int = 0 } object MyOpErrorCase { val hints: Hints = Hints.empty @@ -123,7 +125,7 @@ object NameCollisionOperation { implicit val schema: UnionSchema[MyOpError] = union( MyOpErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Endpoint() extends NameCollisionOperation[Unit, Nothing, Unit, Nothing, Nothing] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala b/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala index 42ae268cb..da92c835a 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala @@ -120,17 +120,19 @@ object ObjectServiceOperation { } sealed trait PutObjectError extends scala.Product with scala.Serializable { @inline final def widen: PutObjectError = this - def _ordinal: Int + def $ordinal: Int } object PutObjectError extends ShapeTag.Companion[PutObjectError] { + + def serverError(serverError:ServerError): PutObjectError = ServerErrorCase(serverError) + def noMoreSpace(noMoreSpace:NoMoreSpace): PutObjectError = NoMoreSpaceCase(noMoreSpace) + val id: ShapeId = ShapeId("smithy4s.example", "PutObjectError") val hints: Hints = Hints.empty - final case class ServerErrorCase(serverError: ServerError) extends PutObjectError { final def _ordinal: Int = 0 } - def serverError(serverError:ServerError): PutObjectError = ServerErrorCase(serverError) - final case class NoMoreSpaceCase(noMoreSpace: NoMoreSpace) extends PutObjectError { final def _ordinal: Int = 1 } - def noMoreSpace(noMoreSpace:NoMoreSpace): PutObjectError = NoMoreSpaceCase(noMoreSpace) + final case class ServerErrorCase(serverError: ServerError) extends PutObjectError { final def $ordinal: Int = 0 } + final case class NoMoreSpaceCase(noMoreSpace: NoMoreSpace) extends PutObjectError { final def $ordinal: Int = 1 } object ServerErrorCase { val hints: Hints = Hints.empty @@ -147,7 +149,7 @@ object ObjectServiceOperation { ServerErrorCase.alt, NoMoreSpaceCase.alt, ){ - _._ordinal + _.$ordinal } } final case class GetObject(input: GetObjectInput) extends ObjectServiceOperation[GetObjectInput, ObjectServiceOperation.GetObjectError, GetObjectOutput, Nothing, Nothing] { @@ -178,15 +180,17 @@ object ObjectServiceOperation { } sealed trait GetObjectError extends scala.Product with scala.Serializable { @inline final def widen: GetObjectError = this - def _ordinal: Int + def $ordinal: Int } object GetObjectError extends ShapeTag.Companion[GetObjectError] { + + def serverError(serverError:ServerError): GetObjectError = ServerErrorCase(serverError) + val id: ShapeId = ShapeId("smithy4s.example", "GetObjectError") val hints: Hints = Hints.empty - final case class ServerErrorCase(serverError: ServerError) extends GetObjectError { final def _ordinal: Int = 0 } - def serverError(serverError:ServerError): GetObjectError = ServerErrorCase(serverError) + final case class ServerErrorCase(serverError: ServerError) extends GetObjectError { final def $ordinal: Int = 0 } object ServerErrorCase { val hints: Hints = Hints.empty @@ -197,7 +201,7 @@ object ObjectServiceOperation { implicit val schema: UnionSchema[GetObjectError] = union( ServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/OpticsUnion.scala b/modules/bootstrapped/src/generated/smithy4s/example/OpticsUnion.scala index cc4e810c7..9a35ca6fb 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/OpticsUnion.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/OpticsUnion.scala @@ -10,9 +10,12 @@ import smithy4s.schema.Schema.union sealed trait OpticsUnion extends scala.Product with scala.Serializable { @inline final def widen: OpticsUnion = this - def _ordinal: Int + def $ordinal: Int } object OpticsUnion extends ShapeTag.Companion[OpticsUnion] { + + def one(one:OpticsStructure): OpticsUnion = OneCase(one) + val id: ShapeId = ShapeId("smithy4s.example", "OpticsUnion") val hints: Hints = Hints.empty @@ -21,8 +24,7 @@ object OpticsUnion extends ShapeTag.Companion[OpticsUnion] { val one: Prism[OpticsUnion, OpticsStructure] = Prism.partial[OpticsUnion, OpticsStructure]{ case OneCase(t) => t }(OneCase.apply) } - final case class OneCase(one: OpticsStructure) extends OpticsUnion { final def _ordinal: Int = 0 } - def one(one:OpticsStructure): OpticsUnion = OneCase(one) + final case class OneCase(one: OpticsStructure) extends OpticsUnion { final def $ordinal: Int = 0 } object OneCase { val hints: Hints = Hints.empty @@ -33,6 +35,6 @@ object OpticsUnion extends ShapeTag.Companion[OpticsUnion] { implicit val schema: Schema[OpticsUnion] = union( OneCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/OrderType.scala b/modules/bootstrapped/src/generated/smithy4s/example/OrderType.scala index 52628241d..7b81c7902 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/OrderType.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/OrderType.scala @@ -14,20 +14,25 @@ import smithy4s.schema.Schema.union */ sealed trait OrderType extends scala.Product with scala.Serializable { @inline final def widen: OrderType = this - def _ordinal: Int + def $ordinal: Int } object OrderType extends ShapeTag.Companion[OrderType] { + + def online(online:OrderNumber): OrderType = OnlineCase(online) + /** For an InStoreOrder a location ID isn't needed */ + def inStoreOrder(id: OrderNumber, locationId: Option[String] = None):InStoreOrder = InStoreOrder(id, locationId) + def preview(): OrderType = PreviewCase + val id: ShapeId = ShapeId("smithy4s.example", "OrderType") val hints: Hints = Hints( smithy.api.Documentation("Our order types have different ways to identify a product\nExcept for preview orders, these don\'t have an ID "), ) - final case class OnlineCase(online: OrderNumber) extends OrderType { final def _ordinal: Int = 0 } - def online(online:OrderNumber): OrderType = OnlineCase(online) + final case class OnlineCase(online: OrderNumber) extends OrderType { final def $ordinal: Int = 0 } /** For an InStoreOrder a location ID isn't needed */ final case class InStoreOrder(id: OrderNumber, locationId: Option[String] = None) extends OrderType { - def _ordinal: Int = 1 + def $ordinal: Int = 1 } object InStoreOrder extends ShapeTag.Companion[InStoreOrder] { val id: ShapeId = ShapeId("smithy4s.example", "InStoreOrder") @@ -45,8 +50,7 @@ object OrderType extends ShapeTag.Companion[OrderType] { val alt = schema.oneOf[OrderType]("inStore") } - case object PreviewCase extends OrderType { final def _ordinal: Int = 2 } - def preview(): OrderType = PreviewCase + case object PreviewCase extends OrderType { final def $ordinal: Int = 2 } private val PreviewCaseAlt = Schema.constant(PreviewCase).oneOf[OrderType]("preview").addHints(hints) object OnlineCase { @@ -60,6 +64,6 @@ object OrderType extends ShapeTag.Companion[OrderType] { InStoreOrder.alt, PreviewCaseAlt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/PersonContactInfo.scala b/modules/bootstrapped/src/generated/smithy4s/example/PersonContactInfo.scala index d43fb8a28..cc50e46b2 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/PersonContactInfo.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/PersonContactInfo.scala @@ -11,9 +11,13 @@ import smithy4s.schema.Schema.union sealed trait PersonContactInfo extends scala.Product with scala.Serializable { @inline final def widen: PersonContactInfo = this - def _ordinal: Int + def $ordinal: Int } object PersonContactInfo extends ShapeTag.Companion[PersonContactInfo] { + + def email(email:PersonEmail): PersonContactInfo = EmailCase(email) + def phone(phone:PersonPhoneNumber): PersonContactInfo = PhoneCase(phone) + val id: ShapeId = ShapeId("smithy4s.example", "PersonContactInfo") val hints: Hints = Hints( @@ -25,10 +29,8 @@ object PersonContactInfo extends ShapeTag.Companion[PersonContactInfo] { val phone: Prism[PersonContactInfo, PersonPhoneNumber] = Prism.partial[PersonContactInfo, PersonPhoneNumber]{ case PhoneCase(t) => t }(PhoneCase.apply) } - final case class EmailCase(email: PersonEmail) extends PersonContactInfo { final def _ordinal: Int = 0 } - def email(email:PersonEmail): PersonContactInfo = EmailCase(email) - final case class PhoneCase(phone: PersonPhoneNumber) extends PersonContactInfo { final def _ordinal: Int = 1 } - def phone(phone:PersonPhoneNumber): PersonContactInfo = PhoneCase(phone) + final case class EmailCase(email: PersonEmail) extends PersonContactInfo { final def $ordinal: Int = 0 } + final case class PhoneCase(phone: PersonPhoneNumber) extends PersonContactInfo { final def $ordinal: Int = 1 } object EmailCase { val hints: Hints = Hints.empty @@ -45,7 +47,7 @@ object PersonContactInfo extends ShapeTag.Companion[PersonContactInfo] { EmailCase.alt, PhoneCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) implicit val personContactInfoHash: cats.Hash[PersonContactInfo] = SchemaVisitorHash.fromSchema(schema) diff --git a/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala b/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala index a449b12e5..3c31dd202 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala @@ -162,20 +162,22 @@ object PizzaAdminServiceOperation { } sealed trait AddMenuItemError extends scala.Product with scala.Serializable { @inline final def widen: AddMenuItemError = this - def _ordinal: Int + def $ordinal: Int } object AddMenuItemError extends ShapeTag.Companion[AddMenuItemError] { - val id: ShapeId = ShapeId("smithy4s.example", "AddMenuItemError") - - val hints: Hints = Hints.empty - final case class PriceErrorCase(priceError: PriceError) extends AddMenuItemError { final def _ordinal: Int = 0 } def priceError(priceError:PriceError): AddMenuItemError = PriceErrorCase(priceError) - final case class GenericServerErrorCase(genericServerError: GenericServerError) extends AddMenuItemError { final def _ordinal: Int = 1 } def genericServerError(genericServerError:GenericServerError): AddMenuItemError = GenericServerErrorCase(genericServerError) - final case class GenericClientErrorCase(genericClientError: GenericClientError) extends AddMenuItemError { final def _ordinal: Int = 2 } def genericClientError(genericClientError:GenericClientError): AddMenuItemError = GenericClientErrorCase(genericClientError) + val id: ShapeId = ShapeId("smithy4s.example", "AddMenuItemError") + + val hints: Hints = Hints.empty + + final case class PriceErrorCase(priceError: PriceError) extends AddMenuItemError { final def $ordinal: Int = 0 } + final case class GenericServerErrorCase(genericServerError: GenericServerError) extends AddMenuItemError { final def $ordinal: Int = 1 } + final case class GenericClientErrorCase(genericClientError: GenericClientError) extends AddMenuItemError { final def $ordinal: Int = 2 } + object PriceErrorCase { val hints: Hints = Hints.empty val schema: Schema[PriceErrorCase] = bijection(PriceError.schema.addHints(hints), PriceErrorCase(_), _.priceError) @@ -197,7 +199,7 @@ object PizzaAdminServiceOperation { GenericServerErrorCase.alt, GenericClientErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class GetMenu(input: GetMenuRequest) extends PizzaAdminServiceOperation[GetMenuRequest, PizzaAdminServiceOperation.GetMenuError, GetMenuResult, Nothing, Nothing] { @@ -234,22 +236,24 @@ object PizzaAdminServiceOperation { } sealed trait GetMenuError extends scala.Product with scala.Serializable { @inline final def widen: GetMenuError = this - def _ordinal: Int + def $ordinal: Int } object GetMenuError extends ShapeTag.Companion[GetMenuError] { - val id: ShapeId = ShapeId("smithy4s.example", "GetMenuError") - - val hints: Hints = Hints.empty - final case class GenericClientErrorCase(genericClientError: GenericClientError) extends GetMenuError { final def _ordinal: Int = 0 } def genericClientError(genericClientError:GenericClientError): GetMenuError = GenericClientErrorCase(genericClientError) - final case class FallbackError2Case(fallbackError2: FallbackError2) extends GetMenuError { final def _ordinal: Int = 1 } def fallbackError2(fallbackError2:FallbackError2): GetMenuError = FallbackError2Case(fallbackError2) - final case class FallbackErrorCase(fallbackError: FallbackError) extends GetMenuError { final def _ordinal: Int = 2 } def fallbackError(fallbackError:FallbackError): GetMenuError = FallbackErrorCase(fallbackError) - final case class NotFoundErrorCase(notFoundError: NotFoundError) extends GetMenuError { final def _ordinal: Int = 3 } def notFoundError(notFoundError:NotFoundError): GetMenuError = NotFoundErrorCase(notFoundError) + val id: ShapeId = ShapeId("smithy4s.example", "GetMenuError") + + val hints: Hints = Hints.empty + + final case class GenericClientErrorCase(genericClientError: GenericClientError) extends GetMenuError { final def $ordinal: Int = 0 } + final case class FallbackError2Case(fallbackError2: FallbackError2) extends GetMenuError { final def $ordinal: Int = 1 } + final case class FallbackErrorCase(fallbackError: FallbackError) extends GetMenuError { final def $ordinal: Int = 2 } + final case class NotFoundErrorCase(notFoundError: NotFoundError) extends GetMenuError { final def $ordinal: Int = 3 } + object GenericClientErrorCase { val hints: Hints = Hints.empty val schema: Schema[GenericClientErrorCase] = bijection(GenericClientError.schema.addHints(hints), GenericClientErrorCase(_), _.genericClientError) @@ -277,7 +281,7 @@ object PizzaAdminServiceOperation { FallbackErrorCase.alt, NotFoundErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Version() extends PizzaAdminServiceOperation[Unit, Nothing, VersionOutput, Nothing, Nothing] { @@ -327,15 +331,17 @@ object PizzaAdminServiceOperation { } sealed trait HealthError extends scala.Product with scala.Serializable { @inline final def widen: HealthError = this - def _ordinal: Int + def $ordinal: Int } object HealthError extends ShapeTag.Companion[HealthError] { + + def unknownServerError(unknownServerError:UnknownServerError): HealthError = UnknownServerErrorCase(unknownServerError) + val id: ShapeId = ShapeId("smithy4s.example", "HealthError") val hints: Hints = Hints.empty - final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends HealthError { final def _ordinal: Int = 0 } - def unknownServerError(unknownServerError:UnknownServerError): HealthError = UnknownServerErrorCase(unknownServerError) + final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends HealthError { final def $ordinal: Int = 0 } object UnknownServerErrorCase { val hints: Hints = Hints.empty @@ -346,7 +352,7 @@ object PizzaAdminServiceOperation { implicit val schema: UnionSchema[HealthError] = union( UnknownServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class HeaderEndpoint(input: HeaderEndpointData) extends PizzaAdminServiceOperation[HeaderEndpointData, Nothing, HeaderEndpointData, Nothing, Nothing] { @@ -411,15 +417,17 @@ object PizzaAdminServiceOperation { } sealed trait GetEnumError extends scala.Product with scala.Serializable { @inline final def widen: GetEnumError = this - def _ordinal: Int + def $ordinal: Int } object GetEnumError extends ShapeTag.Companion[GetEnumError] { + + def unknownServerError(unknownServerError:UnknownServerError): GetEnumError = UnknownServerErrorCase(unknownServerError) + val id: ShapeId = ShapeId("smithy4s.example", "GetEnumError") val hints: Hints = Hints.empty - final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends GetEnumError { final def _ordinal: Int = 0 } - def unknownServerError(unknownServerError:UnknownServerError): GetEnumError = UnknownServerErrorCase(unknownServerError) + final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends GetEnumError { final def $ordinal: Int = 0 } object UnknownServerErrorCase { val hints: Hints = Hints.empty @@ -430,7 +438,7 @@ object PizzaAdminServiceOperation { implicit val schema: UnionSchema[GetEnumError] = union( UnknownServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class GetIntEnum(input: GetIntEnumInput) extends PizzaAdminServiceOperation[GetIntEnumInput, PizzaAdminServiceOperation.GetIntEnumError, GetIntEnumOutput, Nothing, Nothing] { @@ -461,15 +469,17 @@ object PizzaAdminServiceOperation { } sealed trait GetIntEnumError extends scala.Product with scala.Serializable { @inline final def widen: GetIntEnumError = this - def _ordinal: Int + def $ordinal: Int } object GetIntEnumError extends ShapeTag.Companion[GetIntEnumError] { + + def unknownServerError(unknownServerError:UnknownServerError): GetIntEnumError = UnknownServerErrorCase(unknownServerError) + val id: ShapeId = ShapeId("smithy4s.example", "GetIntEnumError") val hints: Hints = Hints.empty - final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends GetIntEnumError { final def _ordinal: Int = 0 } - def unknownServerError(unknownServerError:UnknownServerError): GetIntEnumError = UnknownServerErrorCase(unknownServerError) + final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends GetIntEnumError { final def $ordinal: Int = 0 } object UnknownServerErrorCase { val hints: Hints = Hints.empty @@ -480,7 +490,7 @@ object PizzaAdminServiceOperation { implicit val schema: UnionSchema[GetIntEnumError] = union( UnknownServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class CustomCode(input: CustomCodeInput) extends PizzaAdminServiceOperation[CustomCodeInput, PizzaAdminServiceOperation.CustomCodeError, CustomCodeOutput, Nothing, Nothing] { @@ -511,15 +521,17 @@ object PizzaAdminServiceOperation { } sealed trait CustomCodeError extends scala.Product with scala.Serializable { @inline final def widen: CustomCodeError = this - def _ordinal: Int + def $ordinal: Int } object CustomCodeError extends ShapeTag.Companion[CustomCodeError] { + + def unknownServerError(unknownServerError:UnknownServerError): CustomCodeError = UnknownServerErrorCase(unknownServerError) + val id: ShapeId = ShapeId("smithy4s.example", "CustomCodeError") val hints: Hints = Hints.empty - final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends CustomCodeError { final def _ordinal: Int = 0 } - def unknownServerError(unknownServerError:UnknownServerError): CustomCodeError = UnknownServerErrorCase(unknownServerError) + final case class UnknownServerErrorCase(unknownServerError: UnknownServerError) extends CustomCodeError { final def $ordinal: Int = 0 } object UnknownServerErrorCase { val hints: Hints = Hints.empty @@ -530,7 +542,7 @@ object PizzaAdminServiceOperation { implicit val schema: UnionSchema[CustomCodeError] = union( UnknownServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Reservation(input: ReservationInput) extends PizzaAdminServiceOperation[ReservationInput, Nothing, ReservationOutput, Nothing, Nothing] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Podcast.scala b/modules/bootstrapped/src/generated/smithy4s/example/Podcast.scala index bfba07485..8e00c103c 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Podcast.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Podcast.scala @@ -13,9 +13,13 @@ import smithy4s.schema.Schema.union sealed trait Podcast extends PodcastCommon with scala.Product with scala.Serializable { @inline final def widen: Podcast = this - def _ordinal: Int + def $ordinal: Int } object Podcast extends ShapeTag.Companion[Podcast] { + + def video(title: Option[String] = None, url: Option[String] = None, durationMillis: Option[Long] = None):Video = Video(title, url, durationMillis) + def audio(title: Option[String] = None, url: Option[String] = None, durationMillis: Option[Long] = None):Audio = Audio(title, url, durationMillis) + val id: ShapeId = ShapeId("smithy4s.example", "Podcast") val hints: Hints = Hints.empty @@ -26,7 +30,7 @@ object Podcast extends ShapeTag.Companion[Podcast] { } final case class Video(title: Option[String] = None, url: Option[String] = None, durationMillis: Option[Long] = None) extends Podcast { - def _ordinal: Int = 0 + def $ordinal: Int = 0 } object Video extends ShapeTag.Companion[Video] { val id: ShapeId = ShapeId("smithy4s.example", "Video") @@ -50,7 +54,7 @@ object Podcast extends ShapeTag.Companion[Podcast] { val alt = schema.oneOf[Podcast]("video") } final case class Audio(title: Option[String] = None, url: Option[String] = None, durationMillis: Option[Long] = None) extends Podcast { - def _ordinal: Int = 1 + def $ordinal: Int = 1 } object Audio extends ShapeTag.Companion[Audio] { val id: ShapeId = ShapeId("smithy4s.example", "Audio") @@ -79,6 +83,6 @@ object Podcast extends ShapeTag.Companion[Podcast] { Video.alt, Audio.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/TestAdt.scala b/modules/bootstrapped/src/generated/smithy4s/example/TestAdt.scala index d6f6866c4..82b4fc7ce 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/TestAdt.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/TestAdt.scala @@ -15,15 +15,19 @@ import smithy4s.schema.Schema.union sealed trait TestAdt extends AdtMixinOne with AdtMixinTwo with scala.Product with scala.Serializable { @inline final def widen: TestAdt = this - def _ordinal: Int + def $ordinal: Int } object TestAdt extends ShapeTag.Companion[TestAdt] { + + def adtOne(lng: Option[Long] = None, sht: Option[Short] = None, blb: Option[Blob] = None, str: Option[String] = None):AdtOne = AdtOne(lng, sht, blb, str) + def adtTwo(lng: Option[Long] = None, sht: Option[Short] = None, int: Option[Int] = None):AdtTwo = AdtTwo(lng, sht, int) + val id: ShapeId = ShapeId("smithy4s.example", "TestAdt") val hints: Hints = Hints.empty final case class AdtOne(lng: Option[Long] = None, sht: Option[Short] = None, blb: Option[Blob] = None, str: Option[String] = None) extends TestAdt with AdtMixinThree { - def _ordinal: Int = 0 + def $ordinal: Int = 0 } object AdtOne extends ShapeTag.Companion[AdtOne] { val id: ShapeId = ShapeId("smithy4s.example", "AdtOne") @@ -42,7 +46,7 @@ object TestAdt extends ShapeTag.Companion[TestAdt] { val alt = schema.oneOf[TestAdt]("one") } final case class AdtTwo(lng: Option[Long] = None, sht: Option[Short] = None, int: Option[Int] = None) extends TestAdt { - def _ordinal: Int = 1 + def $ordinal: Int = 1 } object AdtTwo extends ShapeTag.Companion[AdtTwo] { val id: ShapeId = ShapeId("smithy4s.example", "AdtTwo") @@ -65,6 +69,6 @@ object TestAdt extends ShapeTag.Companion[TestAdt] { AdtOne.alt, AdtTwo.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/TestBiggerUnion.scala b/modules/bootstrapped/src/generated/smithy4s/example/TestBiggerUnion.scala index 9a2d1952f..ffe0f6740 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/TestBiggerUnion.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/TestBiggerUnion.scala @@ -9,19 +9,21 @@ import smithy4s.schema.Schema.union sealed trait TestBiggerUnion extends scala.Product with scala.Serializable { @inline final def widen: TestBiggerUnion = this - def _ordinal: Int + def $ordinal: Int } object TestBiggerUnion extends ShapeTag.Companion[TestBiggerUnion] { + + def one(one:One): TestBiggerUnion = OneCase(one) + def two(two:Two): TestBiggerUnion = TwoCase(two) + val id: ShapeId = ShapeId("smithy4s.example", "TestBiggerUnion") val hints: Hints = Hints( alloy.Discriminated("tpe"), ) - final case class OneCase(one: One) extends TestBiggerUnion { final def _ordinal: Int = 0 } - def one(one:One): TestBiggerUnion = OneCase(one) - final case class TwoCase(two: Two) extends TestBiggerUnion { final def _ordinal: Int = 1 } - def two(two:Two): TestBiggerUnion = TwoCase(two) + final case class OneCase(one: One) extends TestBiggerUnion { final def $ordinal: Int = 0 } + final case class TwoCase(two: Two) extends TestBiggerUnion { final def $ordinal: Int = 1 } object OneCase { val hints: Hints = Hints.empty @@ -38,6 +40,6 @@ object TestBiggerUnion extends ShapeTag.Companion[TestBiggerUnion] { OneCase.alt, TwoCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/TestMixinAdt.scala b/modules/bootstrapped/src/generated/smithy4s/example/TestMixinAdt.scala index 81bb21aff..3431fdbe3 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/TestMixinAdt.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/TestMixinAdt.scala @@ -11,15 +11,18 @@ import smithy4s.schema.Schema.union sealed trait TestMixinAdt extends scala.Product with scala.Serializable { @inline final def widen: TestMixinAdt = this - def _ordinal: Int + def $ordinal: Int } object TestMixinAdt extends ShapeTag.Companion[TestMixinAdt] { + + def testAdtMemberWithMixin(a: Option[String] = None, b: Option[Int] = None):TestAdtMemberWithMixin = TestAdtMemberWithMixin(a, b) + val id: ShapeId = ShapeId("smithy4s.example", "TestMixinAdt") val hints: Hints = Hints.empty final case class TestAdtMemberWithMixin(a: Option[String] = None, b: Option[Int] = None) extends TestMixinAdt with CommonFieldsOne { - def _ordinal: Int = 0 + def $ordinal: Int = 0 } object TestAdtMemberWithMixin extends ShapeTag.Companion[TestAdtMemberWithMixin] { val id: ShapeId = ShapeId("smithy4s.example", "TestAdtMemberWithMixin") @@ -40,6 +43,6 @@ object TestMixinAdt extends ShapeTag.Companion[TestMixinAdt] { implicit val schema: Schema[TestMixinAdt] = union( TestAdtMemberWithMixin.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/UnionWithRefinedTypes.scala b/modules/bootstrapped/src/generated/smithy4s/example/UnionWithRefinedTypes.scala index e4093dfe3..2b0f4548d 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/UnionWithRefinedTypes.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/UnionWithRefinedTypes.scala @@ -9,17 +9,19 @@ import smithy4s.schema.Schema.union sealed trait UnionWithRefinedTypes extends scala.Product with scala.Serializable { @inline final def widen: UnionWithRefinedTypes = this - def _ordinal: Int + def $ordinal: Int } object UnionWithRefinedTypes extends ShapeTag.Companion[UnionWithRefinedTypes] { + + def age(age:Age): UnionWithRefinedTypes = AgeCase(age) + def dogName(dogName:smithy4s.refined.Name): UnionWithRefinedTypes = DogNameCase(dogName) + val id: ShapeId = ShapeId("smithy4s.example", "UnionWithRefinedTypes") val hints: Hints = Hints.empty - final case class AgeCase(age: Age) extends UnionWithRefinedTypes { final def _ordinal: Int = 0 } - def age(age:Age): UnionWithRefinedTypes = AgeCase(age) - final case class DogNameCase(dogName: smithy4s.refined.Name) extends UnionWithRefinedTypes { final def _ordinal: Int = 1 } - def dogName(dogName:smithy4s.refined.Name): UnionWithRefinedTypes = DogNameCase(dogName) + final case class AgeCase(age: Age) extends UnionWithRefinedTypes { final def $ordinal: Int = 0 } + final case class DogNameCase(dogName: smithy4s.refined.Name) extends UnionWithRefinedTypes { final def $ordinal: Int = 1 } object AgeCase { val hints: Hints = Hints.empty @@ -36,6 +38,6 @@ object UnionWithRefinedTypes extends ShapeTag.Companion[UnionWithRefinedTypes] { AgeCase.alt, DogNameCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/UntaggedUnion.scala b/modules/bootstrapped/src/generated/smithy4s/example/UntaggedUnion.scala index 642481506..895cd5ac4 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/UntaggedUnion.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/UntaggedUnion.scala @@ -9,19 +9,21 @@ import smithy4s.schema.Schema.union sealed trait UntaggedUnion extends scala.Product with scala.Serializable { @inline final def widen: UntaggedUnion = this - def _ordinal: Int + def $ordinal: Int } object UntaggedUnion extends ShapeTag.Companion[UntaggedUnion] { + + def three(three:Three): UntaggedUnion = ThreeCase(three) + def four(four:Four): UntaggedUnion = FourCase(four) + val id: ShapeId = ShapeId("smithy4s.example", "UntaggedUnion") val hints: Hints = Hints( alloy.Untagged(), ) - final case class ThreeCase(three: Three) extends UntaggedUnion { final def _ordinal: Int = 0 } - def three(three:Three): UntaggedUnion = ThreeCase(three) - final case class FourCase(four: Four) extends UntaggedUnion { final def _ordinal: Int = 1 } - def four(four:Four): UntaggedUnion = FourCase(four) + final case class ThreeCase(three: Three) extends UntaggedUnion { final def $ordinal: Int = 0 } + final case class FourCase(four: Four) extends UntaggedUnion { final def $ordinal: Int = 1 } object ThreeCase { val hints: Hints = Hints.empty @@ -38,6 +40,6 @@ object UntaggedUnion extends ShapeTag.Companion[UntaggedUnion] { ThreeCase.alt, FourCase.alt, ){ - _._ordinal + _.$ordinal }.withId(id).addHints(hints) } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala b/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala index 1650e9118..55adccd22 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala @@ -136,15 +136,17 @@ object WeatherOperation { } sealed trait GetCityError extends scala.Product with scala.Serializable { @inline final def widen: GetCityError = this - def _ordinal: Int + def $ordinal: Int } object GetCityError extends ShapeTag.Companion[GetCityError] { + + def noSuchResource(noSuchResource:NoSuchResource): GetCityError = NoSuchResourceCase(noSuchResource) + val id: ShapeId = ShapeId("smithy4s.example", "GetCityError") val hints: Hints = Hints.empty - final case class NoSuchResourceCase(noSuchResource: NoSuchResource) extends GetCityError { final def _ordinal: Int = 0 } - def noSuchResource(noSuchResource:NoSuchResource): GetCityError = NoSuchResourceCase(noSuchResource) + final case class NoSuchResourceCase(noSuchResource: NoSuchResource) extends GetCityError { final def $ordinal: Int = 0 } object NoSuchResourceCase { val hints: Hints = Hints.empty @@ -155,7 +157,7 @@ object WeatherOperation { implicit val schema: UnionSchema[GetCityError] = union( NoSuchResourceCase.alt, ){ - _._ordinal + _.$ordinal } } final case class GetForecast(input: GetForecastInput) extends WeatherOperation[GetForecastInput, Nothing, GetForecastOutput, Nothing, Nothing] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala b/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala index b01d202b5..bd5e54b7e 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala @@ -113,15 +113,17 @@ object HelloWorldAuthServiceOperation { } sealed trait SayWorldError extends scala.Product with scala.Serializable { @inline final def widen: SayWorldError = this - def _ordinal: Int + def $ordinal: Int } object SayWorldError extends ShapeTag.Companion[SayWorldError] { + + def notAuthorizedError(notAuthorizedError:NotAuthorizedError): SayWorldError = NotAuthorizedErrorCase(notAuthorizedError) + val id: ShapeId = ShapeId("smithy4s.example.guides.auth", "SayWorldError") val hints: Hints = Hints.empty - final case class NotAuthorizedErrorCase(notAuthorizedError: NotAuthorizedError) extends SayWorldError { final def _ordinal: Int = 0 } - def notAuthorizedError(notAuthorizedError:NotAuthorizedError): SayWorldError = NotAuthorizedErrorCase(notAuthorizedError) + final case class NotAuthorizedErrorCase(notAuthorizedError: NotAuthorizedError) extends SayWorldError { final def $ordinal: Int = 0 } object NotAuthorizedErrorCase { val hints: Hints = Hints.empty @@ -132,7 +134,7 @@ object HelloWorldAuthServiceOperation { implicit val schema: UnionSchema[SayWorldError] = union( NotAuthorizedErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class HealthCheck() extends HelloWorldAuthServiceOperation[Unit, HelloWorldAuthServiceOperation.HealthCheckError, HealthCheckOutput, Nothing, Nothing] { @@ -165,15 +167,17 @@ object HelloWorldAuthServiceOperation { } sealed trait HealthCheckError extends scala.Product with scala.Serializable { @inline final def widen: HealthCheckError = this - def _ordinal: Int + def $ordinal: Int } object HealthCheckError extends ShapeTag.Companion[HealthCheckError] { + + def notAuthorizedError(notAuthorizedError:NotAuthorizedError): HealthCheckError = NotAuthorizedErrorCase(notAuthorizedError) + val id: ShapeId = ShapeId("smithy4s.example.guides.auth", "HealthCheckError") val hints: Hints = Hints.empty - final case class NotAuthorizedErrorCase(notAuthorizedError: NotAuthorizedError) extends HealthCheckError { final def _ordinal: Int = 0 } - def notAuthorizedError(notAuthorizedError:NotAuthorizedError): HealthCheckError = NotAuthorizedErrorCase(notAuthorizedError) + final case class NotAuthorizedErrorCase(notAuthorizedError: NotAuthorizedError) extends HealthCheckError { final def $ordinal: Int = 0 } object NotAuthorizedErrorCase { val hints: Hints = Hints.empty @@ -184,7 +188,7 @@ object HelloWorldAuthServiceOperation { implicit val schema: UnionSchema[HealthCheckError] = union( NotAuthorizedErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala b/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala index ab0971f9a..1cfcd6c3e 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala @@ -107,17 +107,19 @@ object HelloWorldServiceOperation { } sealed trait HelloError extends scala.Product with scala.Serializable { @inline final def widen: HelloError = this - def _ordinal: Int + def $ordinal: Int } object HelloError extends ShapeTag.Companion[HelloError] { + + def genericServerError(genericServerError:GenericServerError): HelloError = GenericServerErrorCase(genericServerError) + def specificServerError(specificServerError:SpecificServerError): HelloError = SpecificServerErrorCase(specificServerError) + val id: ShapeId = ShapeId("smithy4s.example.hello", "HelloError") val hints: Hints = Hints.empty - final case class GenericServerErrorCase(genericServerError: GenericServerError) extends HelloError { final def _ordinal: Int = 0 } - def genericServerError(genericServerError:GenericServerError): HelloError = GenericServerErrorCase(genericServerError) - final case class SpecificServerErrorCase(specificServerError: SpecificServerError) extends HelloError { final def _ordinal: Int = 1 } - def specificServerError(specificServerError:SpecificServerError): HelloError = SpecificServerErrorCase(specificServerError) + final case class GenericServerErrorCase(genericServerError: GenericServerError) extends HelloError { final def $ordinal: Int = 0 } + final case class SpecificServerErrorCase(specificServerError: SpecificServerError) extends HelloError { final def $ordinal: Int = 1 } object GenericServerErrorCase { val hints: Hints = Hints.empty @@ -134,7 +136,7 @@ object HelloWorldServiceOperation { GenericServerErrorCase.alt, SpecificServerErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala b/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala index 825d92d73..4f7302ac5 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala @@ -107,15 +107,17 @@ object ImportServiceOperation { } sealed trait ImportOperationError extends scala.Product with scala.Serializable { @inline final def widen: ImportOperationError = this - def _ordinal: Int + def $ordinal: Int } object ImportOperationError extends ShapeTag.Companion[ImportOperationError] { + + def notFoundError(notFoundError:NotFoundError): ImportOperationError = NotFoundErrorCase(notFoundError) + val id: ShapeId = ShapeId("smithy4s.example.imp", "ImportOperationError") val hints: Hints = Hints.empty - final case class NotFoundErrorCase(notFoundError: NotFoundError) extends ImportOperationError { final def _ordinal: Int = 0 } - def notFoundError(notFoundError:NotFoundError): ImportOperationError = NotFoundErrorCase(notFoundError) + final case class NotFoundErrorCase(notFoundError: NotFoundError) extends ImportOperationError { final def $ordinal: Int = 0 } object NotFoundErrorCase { val hints: Hints = Hints.empty @@ -126,7 +128,7 @@ object ImportServiceOperation { implicit val schema: UnionSchema[ImportOperationError] = union( NotFoundErrorCase.alt, ){ - _._ordinal + _.$ordinal } } } diff --git a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala index bc75415ea..b1f9cf9de 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala @@ -116,17 +116,19 @@ object HelloServiceOperation { } sealed trait SayHelloError extends scala.Product with scala.Serializable { @inline final def widen: SayHelloError = this - def _ordinal: Int + def $ordinal: Int } object SayHelloError extends ShapeTag.Companion[SayHelloError] { + + def simpleError(simpleError:SimpleError): SayHelloError = SimpleErrorCase(simpleError) + def complexError(complexError:ComplexError): SayHelloError = ComplexErrorCase(complexError) + val id: ShapeId = ShapeId("smithy4s.example.test", "SayHelloError") val hints: Hints = Hints.empty - final case class SimpleErrorCase(simpleError: SimpleError) extends SayHelloError { final def _ordinal: Int = 0 } - def simpleError(simpleError:SimpleError): SayHelloError = SimpleErrorCase(simpleError) - final case class ComplexErrorCase(complexError: ComplexError) extends SayHelloError { final def _ordinal: Int = 1 } - def complexError(complexError:ComplexError): SayHelloError = ComplexErrorCase(complexError) + final case class SimpleErrorCase(simpleError: SimpleError) extends SayHelloError { final def $ordinal: Int = 0 } + final case class ComplexErrorCase(complexError: ComplexError) extends SayHelloError { final def $ordinal: Int = 1 } object SimpleErrorCase { val hints: Hints = Hints.empty @@ -143,7 +145,7 @@ object HelloServiceOperation { SimpleErrorCase.alt, ComplexErrorCase.alt, ){ - _._ordinal + _.$ordinal } } final case class Listen() extends HelloServiceOperation[Unit, Nothing, Unit, Nothing, Nothing] { diff --git a/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala b/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala index b388c0bb2..6f4cc1d81 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala @@ -948,11 +948,11 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => hints: List[Hint], error: Boolean = false ): Lines = { - def smartConstructor(alt: Alt): Line = { + def smartConstructor(alt: Alt): Lines = { val cn = caseName(alt).name val ident = NameDef(uncapitalise(alt.name)) val prefix = line"def $ident" - alt.member match { + val constructor = alt.member match { case UnionMember.ProductCase(product) => val args = renderArgs(product.fields) val values = product.fields.map(_.name).intercalate(", ") @@ -961,6 +961,11 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => case UnionMember.TypeCase(tpe) => line"$prefix($ident:$tpe): $name = $cn($ident)" } + lines( + documentationAnnotation(alt.hints), + deprecationAnnotation(alt.hints), + constructor + ) } val caseNames = alts.map(caseName) val caseNamesAndIsUnit = @@ -978,9 +983,12 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => line"sealed trait ${NameDef(name.name)} extends ${mixinExtendsStatement}scala.Product with scala.Serializable" )( line"@inline final def widen: $name = this", - line"def _ordinal: Int" + line"def $$ordinal: Int" ), obj(name, line"${shapeTag(name)}")( + newline, + alts.map(smartConstructor), + newline, renderId(shapeId), newline, renderHintsVal(hints), @@ -993,9 +1001,7 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => lines( documentationAnnotation(altHints), deprecationAnnotation(altHints), - line"case object $cn extends $name { final def _ordinal: Int = $index }", - smartConstructor(a), - + line"case object $cn extends $name { final def $$ordinal: Int = $index }", line"""private val ${cn}Alt = $Schema_.constant($cn)${renderConstraintValidation(altHints)}.oneOf[$name]("$realName").addHints(hints)""", ) // format: on @@ -1007,8 +1013,7 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => lines( documentationAnnotation(altHints), deprecationAnnotation(altHints), - line"final case class $cn(${uncapitalise(altName)}: $tpe) extends $name { final def _ordinal: Int = $index }", - smartConstructor(a) + line"final case class $cn(${uncapitalise(altName)}: $tpe) extends $name { final def $$ordinal: Int = $index }" ) case ( Alt(_, realName, UnionMember.ProductCase(struct), altHints), @@ -1026,7 +1031,7 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => struct.copy(hints = altHints ++ struct.hints), adtParent = Some(name), additionalLines, - classBody = Lines(line"def _ordinal: Int = $index") + classBody = Lines(line"def $$ordinal: Int = $index") ) }, newline, @@ -1062,7 +1067,7 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => } } .block { - line"_._ordinal" + line"_.$$ordinal" } .appendToLast( if (error) "" else ".withId(id).addHints(hints)" diff --git a/modules/codegen/test/src/smithy4s/codegen/internals/RendererConfigSpec.scala b/modules/codegen/test/src/smithy4s/codegen/internals/RendererConfigSpec.scala index a9870bee8..49ec3212a 100644 --- a/modules/codegen/test/src/smithy4s/codegen/internals/RendererConfigSpec.scala +++ b/modules/codegen/test/src/smithy4s/codegen/internals/RendererConfigSpec.scala @@ -245,18 +245,18 @@ final class RendererConfigSpec extends munit.FunSuite { assertContainsSection(serviceCode, "sealed trait OperationError")( """|sealed trait OperationError extends scala.Product with scala.Serializable { | @inline final def widen: OperationError = this - | def _ordinal: Int + | def $ordinal: Int |}""".stripMargin ) assertContainsSection(serviceCode, "object OperationError")( """|object OperationError extends ShapeTag.Companion[OperationError] { - | val id: ShapeId = ShapeId("smithy4s.errors", "OperationError") - | val hints: Hints = Hints.empty - | final case class BadRequestCase(badRequest: BadRequest) extends OperationError { final def _ordinal: Int = 0 } | def badRequest(badRequest:BadRequest): OperationError = BadRequestCase(badRequest) - | final case class InternalServerErrorCase(internalServerError: InternalServerError) extends OperationError { final def _ordinal: Int = 1 } | def internalServerError(internalServerError:InternalServerError): OperationError = InternalServerErrorCase(internalServerError) + | val id: ShapeId = ShapeId("smithy4s.errors", "OperationError") + | val hints: Hints = Hints.empty + | final case class BadRequestCase(badRequest: BadRequest) extends OperationError { final def $ordinal: Int = 0 } + | final case class InternalServerErrorCase(internalServerError: InternalServerError) extends OperationError { final def $ordinal: Int = 1 } | object BadRequestCase { | val hints: Hints = Hints.empty | val schema: Schema[BadRequestCase] = bijection(BadRequest.schema.addHints(hints), BadRequestCase(_), _.badRequest) @@ -271,7 +271,7 @@ final class RendererConfigSpec extends munit.FunSuite { | BadRequestCase.alt, | InternalServerErrorCase.alt, | ){ - | _._ordinal + | _.$ordinal | } |}""".stripMargin )