Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Fix $ref serialization errors for requestBodies and responses#1033

Merged
millicentachieng merged 6 commits intovnextmicrosoft/OpenAPI.NET:vnextfrom
fix/ma/ref-serialization-errorsmicrosoft/OpenAPI.NET:fix/ma/ref-serialization-errorsCopy head branch name to clipboard
Oct 6, 2022
Merged

Fix $ref serialization errors for requestBodies and responses#1033
millicentachieng merged 6 commits intovnextmicrosoft/OpenAPI.NET:vnextfrom
fix/ma/ref-serialization-errorsmicrosoft/OpenAPI.NET:fix/ma/ref-serialization-errorsCopy head branch name to clipboard

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'

src/Microsoft.OpenApi/Models/OpenApiDocument.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs Outdated Show resolved Hide resolved
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.