I'm trying to set up Swagger in a Scala project and running into issues referencing schemas in another file.
My folder structure for this is (the swagger folder has all the swagger-ui stuff):
- docs
- swagger.yml
- models
- test_model.yaml
- swagger
- index.html
- swagger-ui.css etc....
My swagger file references the index.html file and it loads fine. All schemas that I define inside the swagger.yml file are loading and showing up correctly. However, when I try to reference a file inside models such as test_model.yaml. I get a 406 error on it loading the test_model.yaml file
Resource representation is only available with these types:
application/octet-stream
My akka set up for the routes for this is:
path("swagger") {
getFromFile("docs/swagger/index.html") } ~
getFromDirectory("docs/swagger") ~
getFromDirectory("docs")
The first two seem to do what I expect. My swagger ui page loads correctly and all of my routes/schemas defined in swagger.yml load fine. However, when I use
$ref: './models/test_model.yaml#/components/schemas/Test'
It throws a 406 error when trying to load the test_model.yaml file. The schemas are all defined correctly and if I keep them defined in the original swagger.yml file and reference them inside there it works fine. It is only when I put them into an outside file.
CodePudding user response:
Ok I finally got it working. I had to add a custom ContentResolver for these routes to map the type for these files to application/yaml
instead of the default resolver mapping them to Octet.