-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore non-model JSON imports (#290)
- Loading branch information
Showing
10 changed files
with
202 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
modules/lsp/src/main/scala/playground/lsp/util/SerializedSmithyModel.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,21 @@ | ||
package playground.lsp.util | ||
|
||
import cats.implicits._ | ||
|
||
case class SerializedSmithyModel( | ||
smithy: String | ||
) | ||
|
||
object SerializedSmithyModel { | ||
import com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec | ||
import com.github.plokhotnyuk.jsoniter_scala.core._ | ||
import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker | ||
|
||
private implicit val c: JsonValueCodec[SerializedSmithyModel] = JsonCodecMaker.make | ||
|
||
val decode: Array[Byte] => Either[Throwable, SerializedSmithyModel] = | ||
bytes => | ||
Either | ||
.catchNonFatal(readFromArray[SerializedSmithyModel](bytes)) | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
modules/lsp/src/test/resources/test-workspaces/json-models/input.smithyql
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 @@ | ||
use service weather#WeatherService |
3 changes: 3 additions & 0 deletions
3
modules/lsp/src/test/resources/test-workspaces/json-models/smithy-build.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,3 @@ | ||
{ | ||
"imports": ["src"] | ||
} |
73 changes: 73 additions & 0 deletions
73
modules/lsp/src/test/resources/test-workspaces/json-models/src/valid-smithy-model.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,73 @@ | ||
{ | ||
"smithy": "2.0", | ||
"shapes": { | ||
"weather#GetWeather": { | ||
"type": "operation", | ||
"input": { | ||
"target": "weather#GetWeatherInput" | ||
}, | ||
"output": { | ||
"target": "weather#GetWeatherOutput" | ||
}, | ||
"traits": { | ||
"smithy.api#readonly": {} | ||
} | ||
}, | ||
"weather#GetWeatherInput": { | ||
"type": "structure", | ||
"members": { | ||
"city": { | ||
"target": "smithy.api#String", | ||
"traits": { | ||
"smithy.api#httpLabel": {}, | ||
"smithy.api#required": {} | ||
} | ||
} | ||
}, | ||
"traits": { | ||
"smithy.api#input": {} | ||
} | ||
}, | ||
"weather#GetWeatherOutput": { | ||
"type": "structure", | ||
"members": { | ||
"weather": { | ||
"target": "weather#Weather", | ||
"traits": { | ||
"smithy.api#required": {} | ||
} | ||
} | ||
}, | ||
"traits": { | ||
"smithy.api#output": {} | ||
} | ||
}, | ||
"weather#GoodWeather": { | ||
"type": "structure", | ||
"members": { | ||
"reallyGood": { | ||
"target": "smithy.api#Boolean" | ||
} | ||
} | ||
}, | ||
"weather#Weather": { | ||
"type": "union", | ||
"members": { | ||
"good": { | ||
"target": "weather#GoodWeather" | ||
}, | ||
"decent": { | ||
"target": "smithy.api#Unit" | ||
} | ||
} | ||
}, | ||
"weather#WeatherService": { | ||
"type": "service", | ||
"operations": [ | ||
{ | ||
"target": "weather#GetWeather" | ||
} | ||
] | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
modules/lsp/src/test/resources/test-workspaces/non-model-jsons/smithy-build.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,3 @@ | ||
{ | ||
"imports": ["src"] | ||
} |
3 changes: 3 additions & 0 deletions
3
modules/lsp/src/test/resources/test-workspaces/non-model-jsons/src/not-a-smithy-model.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,3 @@ | ||
{ | ||
"this": "is not a Smithy model file" | ||
} |
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