Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix $ref serialization errors for requestBodies and responses #1033

Merged
merged 6 commits into from
Oct 6, 2022

Conversation

millicentachieng
Copy link
Member

@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 and others added 2 commits October 6, 2022 17:05
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
@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
2 participants