guardrail-dev / guardrail-dev/guardrail

OAS 3.0 file upload generation fails

Open
#552 2 comments 0 reactions 0 assignees View on GitHub
core enhancement help wanted question scala
Dominant language
Scala
Stars
541
Forks
138
PR merge metrics
No merged PRs in 30d

Description

Trying to upgrade existing Guardrails project from 0.41.1 to 0.55.4 and Swagger 2 to OpenAPI 3, and having issues with file uploads. Guardrails is generating Akka Http endpoints.

When trying to attempt either recommended solution on the OAS website (https://swagger.io/docs/specification/describing-request-body/file-upload/) to posting a file upload, guardrails is generating errors.

Attempt 1:
```
openapi: 3.0.2
...
/uploadendpoint:
post:
...
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
```
This fails to generate with `Error:Unable to generate decoder for application/octet-streams`

Attempt 2:
```
openapi: 3.0.2
...
/uploadendpoint:
post:
...
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
required:
- file
```
This fails to generate with `Unable to generate decoder for multipart/form-data`

It would be good not to have to post application/json and post a base64 encoded field (if that works, but not tested). The second attempt above is compatible with the old API and Swagger 2 (not the same way of declaring, but clients at runtime are compatible).

Perhaps I am doing something dumb, in which case I apologise in advance. Any help would be appreciated, and a confirmation what is possible would be great.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.