APIs-guru / google-discovery-to-swagger

Script for converting Google Discovery format into OpenAPI (swagger) 3.0
MIT License
59 stars 17 forks source link

Handle supportsMediaUpload. #11

Closed chingor13 closed 7 years ago

chingor13 commented 7 years ago

If there is a method that supportsMediaUpload, then we expand that method into up to 3 separate paths (original, simple, and resumable).

The simple and resumable methods share most attributes with the original method, while adding a few implied parameters (from the documentation).

Since the upload paths are relative to / and not the basePath, we must also set the basePath to "/" and prepend the original basePath to each non upload path.

This is part of #9.

Note that processMethod changes its return from an method object to a collection of method objects (keyed by the path and http method). This output is merged into the full collection in processMethodList.

MikeRalphson commented 7 years ago

@chingor13 I'm seeing validation errors, I think on the new parameters which are being merged in: data and metadata. It is not possible to have both an in:body and and in:formData parameter on the same operation. Should these both be formData for multipart uploads?

The first discovery doc I see failing is https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest

chingor13 commented 7 years ago

Looks like you're right. I didn't see that you couldn't have body and formData sections.

Unfortunately, it looks like OpenAPI won't let you specify a schema type for formData fields. For Google file uploads, the metadata field has a schema type. I'll probably have to change the metadata field to be type string and add a vendor extension like x-upload-schema.

MikeRalphson commented 7 years ago

Yes, support for structured body fields is improved in OpenAPI 3.0.0.