Skip to content

Commit

Permalink
Update readme validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Baccata committed Dec 12, 2023
1 parent bfaa455 commit e4be6ce
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions modules/readme-validator/src/Validator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import java.nio.file.Path
import scala.jdk.CollectionConverters._
import scala.util.control.NoStackTrace
import smithyproto.proto3.{Compiler => ProtoCompiler, ModelPreProcessor}
import smithytranslate.openapi.OpenApiCompiler
import smithytranslate.compiler._
import smithytranslate.compiler.openapi._
import smithytranslate.compiler.json_schema._
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.shapes.SmithyIdlModelSerializer
import smithytranslate.json_schema.JsonSchemaCompiler

object Validator {

Expand Down Expand Up @@ -87,7 +88,7 @@ object Validator {
|
|$smithy""".stripMargin
val options =
OpenApiCompiler.Options(
ToSmithyCompilerOptions(
useVerboseNames = false,
validateInput = true,
validateOutput = true,
Expand All @@ -96,16 +97,18 @@ object Validator {
debug = false
)
val result =
OpenApiCompiler.parseAndCompile(
OpenApiCompiler.compile(
options,
(NonEmptyList.of(namespace), openapi)
OpenApiCompilerInput.UnparsedSpecs(
List(FileContents(NonEmptyList.of(namespace), openapi))
)
)
result match {
case OpenApiCompiler.Failure(err, _) =>
case ToSmithyResult.Failure(err, _) =>
List(
ValidationError.UnableToProduceOutput(err.getMessage)
)
case OpenApiCompiler.Success(errors, expectedModel) =>
case ToSmithyResult.Success(errors, expectedModel) =>
val actualModel = Model
.assembler()
.discoverModels()
Expand Down Expand Up @@ -135,7 +138,7 @@ object Validator {
|
|$smithy""".stripMargin
val options =
OpenApiCompiler.Options(
ToSmithyCompilerOptions(
useVerboseNames = false,
validateInput = true,
validateOutput = true,
Expand All @@ -144,16 +147,18 @@ object Validator {
debug = false
)
val result =
JsonSchemaCompiler.parseAndCompile(
JsonSchemaCompiler.compile(
options,
(NonEmptyList.of(namespace), json)
JsonSchemaCompilerInput.UnparsedSpecs(
List(FileContents(NonEmptyList.of(namespace), json))
)
)
result match {
case OpenApiCompiler.Failure(err, _) =>
case ToSmithyResult.Failure(err, _) =>
List(
ValidationError.UnableToProduceOutput(err.getMessage)
)
case OpenApiCompiler.Success(errors, expectedModel) =>
case ToSmithyResult.Success(errors, expectedModel) =>
val actualModel = Model
.assembler()
.discoverModels()
Expand Down

0 comments on commit e4be6ce

Please sign in to comment.