swagger document for multipart/related

530 views
Skip to first unread message

Siva S

unread,
Oct 31, 2016, 2:15:44 PM10/31/16
to Swagger
We are trying to develop a Web API similar to google drive file upload API (https://developers.google.com/drive/v3/web/manage-uploads#multipart) and currently designing swagger document for the same. The post method's request body will have metadata and file, Multiple files will be delimited by some boundary values. We need help in defining swagger document for this with multipart/related content type

I have given the swagger file created below. Please help me in fixing the document.

Thanks in advance
Siva

##############################################################
# HEADER                                                     #
##############################################################
swagger: '2.0'
info:
  title: File
  version: '2016.10.25'
  description: 'description here.'
basePath: /upload/File
schemes:
  - https
##############################################################
# ENDPOINTS                                                  #
##############################################################
paths:
  /content:
     post:
       summary: File
       operationId: File Create
       description: Creates a File resource.
       consumes:
         - multipart/related
       produces:
         - application/files-v1+json
       parameters:
         - name: body
           in: body
           required: true
           description: File to be created.
           schema:
             $ref: '#/definitions/FileCollectionPost'
       responses:
         201:
           description: Created
           headers:
             Location: 
               description: URL of the new File resource.
               type: string
           schema:
             $ref: '#/definitions/File'
         400:
           description: Bad Request - Invalid parameters
         401:
           description: Unauthorized
         403:
           description: Forbidden
         406:
           description: Request Not Acceptable
         409:
           description: Conflict
         415:
           description: Unsupported Media Type
         500:
           description: Internal Server Error - Try again if you like.
##############################################################
# DEFINITIONS                                                #
##############################################################
definitions:
  File:
    type: object
    properties:
      id:
        type: string
        description: Unique ID (GUI ID) of the file.
        example: er123ieowo
      serialNumber:
        description: Serial number of asset.
        type: string
        example: pdfs1232ds      
      userID:
        description: UserID of the file uploader.
        type: string
        example: sampleuser
      latitude:
        description: Latitude value of the location from where the file being uploaded.
        type: number
        format: double
      longitude:
        description: Longitude value of the location from where the file being uploaded.
        type: number
        format: double
  FileCollectionPost:
    type: object
    properties:
      type:
        description: Type of file. 
        type: string
        format: custom
        enum:
          - Value1
          - Value2
          - Value3
        example: Value1 
      fileName:
        description: Name of the file being uploaded with extension.
        type: string
        example: abc.pdf
      latitude: 
        type: number
        format: double
        description: The angular distance of a place north or south of the earth’s equator.
        minimum: -90
        maximum: 90
        example: 42
      longitude: 
        type: number
        format: double
        description: The angular distance, in degrees, minutes, and seconds, of a point east or west of the Prime Meridian.
        minimum: -180
        maximum: 180
        example: 12.04      
      fileToUpload:
        type: string
        description: File to be created.
        format: binary
      properties:
        additionalProperties:
          type: string
        description: |-
          A collection of arbitrary key-value pairs which are visible to all apps.
          Entries with null values are cleared in update and copy requests.
        type: object

Siva S

unread,
Oct 31, 2016, 2:18:59 PM10/31/16
to Swagger
Added the yaml document
swagger.yaml

Ron Ratovsky

unread,
Oct 31, 2016, 5:22:17 PM10/31/16
to swagger-sw...@googlegroups.com

What issues are you having?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Siva S

unread,
Nov 1, 2016, 2:11:43 AM11/1/16
to Swagger
Thanks for the reply Ron. I wanted to confirm whether the attached document is fine? Also do we need to mention the actual file to be uploaded as a property in the request schema definition?

Thanks
Siva

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages