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

OpenAPI: Set properties of objects nested in arrays #600

Merged
merged 1 commit into from
Jan 8, 2023

Conversation

Floppy012
Copy link
Contributor

@Floppy012 Floppy012 commented Jan 6, 2023

When generating the documentation, the OpenAPI does not include properties of objects that are nested in arrays. This PR aims at fixing this bug.

Before:
openapi: 3.0.3
info:
  title: 'Test'
  version: 1.0.0
paths:
  /api/test:
    get:
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                example:
                  someArray:
                    - anotherObjectKey: objectValue
                properties:
                  someArray:
                    type: array
                    example:
                      anotherObjectKey: objectValue
                    items:
                      type: object
After:
openapi: 3.0.3
info:
  title: 'Test'
  version: 1.0.0
paths:
  /api/test:
    get:
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                example:
                  someArray:
                    - anotherObjectKey: objectValue
                properties:
                  someArray:
                    type: array
                    example:
                      anotherObjectKey: objectValue
                    items:
                      type: object
                      properties:
                        anotherObjectKey:
                          type: string
                          example: objectValue
Diff:
--- a/before
+++ b/after
@@ -22,3 +22,7 @@ paths:
                       anotherObjectKey: objectValue
                     items:
                       type: object
+                      properties:
+                        anotherObjectKey:
+                          type: string
+                          example: objectValue

@shalvah shalvah merged commit a97f7ae into knuckleswtf:master Jan 8, 2023
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.

2 participants