Skip to content

Display schema for mutipart/form-data object properties #9756

Description

@AlexisAmd

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.3
info:
 title: Example app
 description: This is an example
 version: 1.0.0
servers:
 - url: https://dev.app.com/appApplicationName
   description: DEV
paths:
 /documents:
   post:
     description: >
       The structure of the *metadata* property should conform to the schema
       defined in the
       [ModelPostDocumentInvoice](#/components/schemas/ModelPostDocumentInvoice)
       schema outlined at the bottom of this page. summary: Multipart/form-data
       with json object property + file
     requestBody:
       content:
         multipart/form-data:
           schema:
             $ref: '#/components/schemas/ModelPostDocumentInvoiceCombineModelFile'
     operationId: test2
     responses:
       '200':
         description: ok
         content:
           application/json:
             schema:
               type: string
               description: ok
components:
 schemas:
   ModelFile:
     type: object
     properties:
       file:
         type: string
         format: binary
     required:
       - file
   AbstractModelPostDocument:
     type: object
     properties:
       title:
         type: string
         default: ''
         maxLength: 64
         example: MyDocument.pdf'
         description: Displayed title. Can be different than filename
       category:
         type: string
         enum:
           - Invoice
           - Receipt
           - Credit note
           - Purchase Order
       documentDate:
         type: string
         description: >-
           Creation date of the document. Example : For ID card, it is the
           issuing date of the card.
         format: date
     required:
       - title
       - category
       - documentDate
   ModelPostDocumentInvoice:
     allOf:
       - $ref: '#/components/schemas/AbstractModelPostDocument'
       - type: object
         properties:
           amount:
             type: number
             example: 1234.56
             description: Invoice Amount
         description: Metadata for invoice documents
         required:
           - amount
   ModelPostDocumentOneOf:
     oneOf:
       - $ref: '#/components/schemas/ModelPostDocumentInvoice'
   ModelPostDocumentInvoiceCombineModelFile:
     allOf:
       - $ref: '#/components/schemas/ModelFile'
       - type: object
         properties:
           metadata:
             $ref: '#/components/schemas/ModelPostDocumentInvoice'
         description: metadata
         required:
           - metadata
   ModelPostDocumentOneOfCombineModelFile:
     allOf:
       - $ref: '#/components/schemas/ModelFile'
       - type: object
         properties:
           metadata:
             $ref: '#/components/schemas/ModelPostDocumentOneOf'
         required:
           - metadata

Is your feature request related to a problem?

In the example provided the 'metadata' which is an object property property is defined using a schema.
After clicking on 'Try it out' an example based on this schema is displayed, however the schema is not displayed in Swagger UI.

Consequently :

  • As API provider I have to provide a link in description to inform consummer that the json for the property should follow the schema
    image

  • As API consumer I have to scroll down to the bottom of the OAS definition to display the schema.
    image

Describe the solution you'd like

With the impovement, for each obect property, the user is allowed to choose between 'Example value' and 'Schema'
image

Describe alternatives you've considered

Current solution : Add link to the schema in endpoint's description

Additional context

The purpose of this endpoint is to offer a versatile method for uploading files and associated metadata of various types. The set of metadata required depends on the nature of the file, such as Invoicing or Identification documents (see Schemas for examples).

Related issues :

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions