Skip to content

Conversation

@millicentachieng
Copy link
Contributor

@millicentachieng millicentachieng commented Oct 6, 2022

Fixes #1000

This PR

  • Converts ref requestBodies to ref parameters in v2 serialization
  • Adds consumes and produces properties when there are ref requestBodies and responses in v2 serialization

Example with ref Request Body

paths:
    '/Documents({Id})/Revisions/$ref':
        post:
          tags:
            - Documents.RevisionDto
          summary: Create new navigation property ref to Revisions for Documents
          operationId: Documents.CreateRefRevisions
-       consumes: [ ]
+       consumes: 
+            - application/json
        parameters:
            - in: path
              name: Id
              description: 'key: Id of DocumentDto'
              required: true
              type: integer
              format: int32
              maximum: 2147483647
              minimum: -2147483648
              x-ms-docs-key-type: DocumentDto
-        - in: body
-            name: body
-            schema: { }
+        - $ref: '#/parameters/refPostBody'
        responses:
            '204':
              description: Success
            default:
              $ref: '#/responses/error'
         x-ms-docs-operation-type: operation
parameters:
+  refPostBody:
+    in: body
+    name: body
+    description: New navigation property ref value
+    required: true
+    schema:
+      $ref: '#/definitions/ReferenceCreate'

Example with ref Response

paths:
    '/Tasks({Id})/Default.Upload':
        post:
          tags:
            - Tasks.Actions
          summary: Invoke action Upload
          operationId: Tasks.DocumentDto.Upload
+          produces:
+            - application/json
          parameters:
            - in: path
              name: Id
              description: 'key: Id of DocumentDto'
              required: true
              type: integer
              format: int32
              maximum: 2147483647
              minimum: -2147483648
              x-ms-docs-key-type: DocumentDto
          responses:
            '200':
              $ref: '#/responses/UploadResponse'
            default:
              $ref: '#/responses/error'
          x-ms-docs-operation-type: action
        x-description: Provides operations to call the Upload method.
responses:
    UploadResponse:
        description: Success
        schema:
          $ref: '#/definitions/Siterra.Documents.App.DTO.DocumentDto'

@millicentachieng millicentachieng force-pushed the fix/ma/ref-serialization-errors branch from fc5d8ea to 1de587c Compare October 6, 2022 16:17
@millicentachieng millicentachieng merged commit 76321be into vnext Oct 6, 2022
@millicentachieng millicentachieng deleted the fix/ma/ref-serialization-errors branch October 6, 2022 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing content type when serializing Responses that are references in v2

3 participants