-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for imports from sub-packages (#98)
- Loading branch information
Showing
8 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
modules/example/resources/smithy4s.example.ImportService.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"openapi": "3.0.2", | ||
"info": { | ||
"title": "ImportService", | ||
"version": "1.0.0" | ||
}, | ||
"paths": { | ||
"/test": { | ||
"get": { | ||
"operationId": "ImportOperation", | ||
"responses": { | ||
"200": { | ||
"description": "ImportOperation 200 response", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/ImportOperationOutputPayload" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"ImportOperationOutputPayload": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.example.import_test.OpOutput | ||
import smithy4s.syntax._ | ||
|
||
trait ImportServiceGen[F[_, _, _, _, _]] { | ||
self => | ||
|
||
def importOperation() : F[Unit, Nothing, OpOutput, Nothing, Nothing] | ||
|
||
def transform[G[_, _, _, _, _]](transformation : smithy4s.Transformation[F, G]) : ImportServiceGen[G] = new Transformed(transformation) | ||
class Transformed[G[_, _, _, _, _]](transformation : smithy4s.Transformation[F, G]) extends ImportServiceGen[G] { | ||
def importOperation() = transformation[Unit, Nothing, OpOutput, Nothing, Nothing](self.importOperation()) | ||
} | ||
} | ||
|
||
object ImportServiceGen extends smithy4s.Service[ImportServiceGen, ImportServiceOperation] { | ||
|
||
def apply[F[_]](implicit F: smithy4s.Monadic[ImportServiceGen, F]): F.type = F | ||
|
||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "ImportService") | ||
|
||
val hints : smithy4s.Hints = smithy4s.Hints( | ||
id, | ||
smithy4s.api.SimpleRestJson(), | ||
) | ||
|
||
val endpoints = List( | ||
ImportOperation, | ||
) | ||
|
||
val version: String = "1.0.0" | ||
|
||
def endpoint[I, E, O, SI, SO](op : ImportServiceOperation[I, E, O, SI, SO]) = op match { | ||
case ImportOperation() => ((), ImportOperation) | ||
} | ||
|
||
object reified extends ImportServiceGen[ImportServiceOperation] { | ||
def importOperation() = ImportOperation() | ||
} | ||
|
||
def transform[P[_, _, _, _, _]](transformation: smithy4s.Transformation[ImportServiceOperation, P]): ImportServiceGen[P] = reified.transform(transformation) | ||
|
||
def transform[P[_, _, _, _, _], P1[_, _, _, _, _]](alg: ImportServiceGen[P], transformation: smithy4s.Transformation[P, P1]): ImportServiceGen[P1] = alg.transform(transformation) | ||
|
||
def asTransformation[P[_, _, _, _, _]](impl : ImportServiceGen[P]): smithy4s.Transformation[ImportServiceOperation, P] = new smithy4s.Transformation[ImportServiceOperation, P] { | ||
def apply[I, E, O, SI, SO](op : ImportServiceOperation[I, E, O, SI, SO]) : P[I, E, O, SI, SO] = op match { | ||
case ImportOperation() => impl.importOperation() | ||
} | ||
} | ||
case class ImportOperation() extends ImportServiceOperation[Unit, Nothing, OpOutput, Nothing, Nothing] | ||
object ImportOperation extends smithy4s.Endpoint[ImportServiceOperation, Unit, Nothing, OpOutput, Nothing, Nothing] { | ||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example.import_test", "ImportOperation") | ||
val input: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Input) | ||
val output: smithy4s.Schema[OpOutput] = OpOutput.schema.withHints(smithy4s.internals.InputOutput.Output) | ||
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing | ||
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing | ||
val hints : smithy4s.Hints = smithy4s.Hints( | ||
id, | ||
smithy.api.Http(smithy.api.NonEmptyString("GET"), smithy.api.NonEmptyString("/test"), Some(200)), | ||
) | ||
def wrap(input: Unit) = ImportOperation() | ||
} | ||
} | ||
|
||
sealed trait ImportServiceOperation[Input, Err, Output, StreamedInput, StreamedOutput] |
19 changes: 19 additions & 0 deletions
19
modules/example/src/smithy4s/example/import_test/OpOutput.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package smithy4s.example.import_test | ||
|
||
import smithy4s.syntax._ | ||
|
||
case class OpOutput(output: String) | ||
object OpOutput extends smithy4s.ShapeTag.Companion[OpOutput] { | ||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example.import_test", "OpOutput") | ||
|
||
val hints : smithy4s.Hints = smithy4s.Hints( | ||
id, | ||
) | ||
|
||
val schema: smithy4s.Schema[OpOutput] = struct( | ||
string.required[OpOutput]("output", _.output).withHints(smithy.api.Required(), smithy.api.HttpPayload()), | ||
){ | ||
OpOutput.apply | ||
}.withHints(hints) | ||
implicit val staticSchema : schematic.Static[smithy4s.Schema[OpOutput]] = schematic.Static(schema) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace smithy4s.example | ||
|
||
use smithy4s.api#simpleRestJson | ||
use smithy4s.example.import_test#ImportOperation | ||
|
||
@simpleRestJson | ||
service ImportService { | ||
version: "1.0.0", | ||
operations: [ImportOperation] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace smithy4s.example.import_test | ||
|
||
@http(method: "GET", uri: "/test", code: 200) | ||
operation ImportOperation { | ||
output: OpOutput | ||
} | ||
|
||
structure OpOutput { | ||
@httpPayload | ||
@required | ||
output: String | ||
} |