JuliaComputing / OpenAPI.jl

OpenAPI helper and code generator for Julia
Other
43 stars 8 forks source link

Is this correct server function signature to response a file? #50

Closed NeroBlackstone closed 1 year ago

NeroBlackstone commented 1 year ago

For download.yaml :

paths:
  /report:
    get:
      summary: Returns the report in the PDF format
      responses:
        '200':
          description: A PDF file
          content:
            application/pdf:
              schema:
                type: string
                format: binary

Julia server generate doc is:

@doc raw"""
Encapsulates generated server code for DownloadServer

The following server methods must be implemented:

- **report_get**
    - *invocation:* GET /report
    - *signature:* report_get(req::HTTP.Request;) -> String
"""

report_get(req::HTTP.Request;) -> String, is this the expected result?

NeroBlackstone commented 1 year ago

Another question is how to implement this report_get function.

Shall we manually set the content-type for response in server implementation?

I think this part is not finished because I can't find any code snip about "application/pdf" in server-generated code.

tanmaykm commented 1 year ago

There have been some related changes to code generation in the openapi-generator repo... so if you try the master branch of openapi-generator, it should generate report_get(req::HTTP.Request;) -> Vector{UInt8} instead.

tanmaykm commented 1 year ago

Shall we manually set the content-type for response in server implementation? I think this part is not finished ...

True, this part is not there. This is what #25 was meant for. But I would recommend addressing that after #51, which can be done in isolation.