guardrail
guardrail copied to clipboard
Missing type mapping for class io.swagger.v3.oas.models.media.Schema
Hi! I have a quite big OASv3 yaml file and was trying out guardrail to generate http4s server.
plugins.sbt
...
addSbtPlugin("dev.guardrail" % "sbt-guardrail" % "0.75.0")
build.sbt
...
Compile / guardrailTasks := List(
ScalaServer(
file(".") / "documentation" / "api" / "backend.yaml",
framework = "http4s",
pkg = "com.example.server"
)
)
After running compile
I get the following error:
WARNING: Missing type mapping for class io.swagger.v3.oas.models.media.Schema, please report this at https://github.com/guardrail-dev/guardrail/issues
Error:Missing type
[error] (Compile / guardrail) dev.guardrail.sbt.CodegenFailedException
which is quite confusing and it prevents me from troubleshooting.
And is there a way to enable more logs?
Ok, I got the troublemaker
I got format: string
instead of type: string
in request schema.
- in: path
name: propertyName
schema:
format: string
required: true
Fixing it solved the issue.
But I think errors should be more informative. Maybe point to a specific path where issue happened?
Also discovered another error(?):
servers:
- url: /api/1-dev/
fails with
Error:Failed to parse URL: endOfInput (unparsed: /datasets/) (.paths./datasets/)
[error] (Compile / guardrail) dev.guardrail.sbt.CodegenFailedException
/datasets/
-- the first api url in the spec
while
servers:
- url: /api/1-dev
doesn't
Also discovered another error(?):
servers: - url: /api/1-dev/
fails with
Error:Failed to parse URL: endOfInput (unparsed: /datasets/) (.paths./datasets/) [error] (Compile / guardrail) dev.guardrail.sbt.CodegenFailedException
/datasets/
-- the first api url in the specwhile
servers: - url: /api/1-dev
doesn't
That was unexpected
Ok, I got the troublemaker
I got
format: string
instead oftype: string
in request schema.- in: path name: propertyName schema: format: string required: true
Fixing it solved the issue.
But I think errors should be more informative. Maybe point to a specific path where issue happened?
Totally agree. I haven't had time to research this, but I'm actually really surprised that the error isn't more descriptive, this is the whole reason I wrote Tracker[?]
OK, I found the issue with the error log, fix to go out with the next release. Having done the exact same thing, digging through extraordinarily large OpenAPI specs to find an error, I really apologize for that user experience.
Looking at the second issue with the path now.
OK, split out #1594 and issued a patch for that one as well.
Thank you for the report(s)!
OK, "dev.guardrail" %% "guardrail-core" % "0.75.2"
is being released right now. If you add that as a libraryDependency
in your project/plugins.sbt
then both of the reported issues here should no longer be an issue.
Awesome, thank you! 👍