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 nested objects properties #587

Merged
merged 2 commits into from
Dec 13, 2022
Merged

Openapi nested objects properties #587

merged 2 commits into from
Dec 13, 2022

Conversation

AdamiecRadek
Copy link
Contributor

@AdamiecRadek AdamiecRadek commented Dec 13, 2022

This PR adds a generation of property types for nested objects inside responses during openapi generation.
Previously if the response contained nested objects, it was marked simply as object, and no additional params were generated. Now OpenAPISpecWriter.php will iterate through its properties and generate specs for them.

Previously

'201':
  description: ''
  content:
    application/json:
      schema:
        type: object
        #example: ...
        properties:
          this:
            type: string
            example: shouldn't be ignored
          and this:
            type: string
            example: too
            description: Parameter description, ha!
          sub level 0:
            type: object
            example:
              sub level 1 key 1: sl0_sl1k1
              sub level 1 key 2:
              - sub level 2 key 1: sl0_sl1k2_sl2k1
                sub level 2 key 2:
                  sub level 3 key 1: sl0_sl1k2_sl2k2_sl3k1
              sub level 1 key 3:
                sub level 2 key 1: sl0_sl1k3_sl2k2
                sub level 2 key 2:
                  sub level 3 key 1: sl0_sl1k3_sl2k2_sl3k1
                  sub level 3 key null:
                  sub level 3 key integer: 99
'204':
  description: Successfully updated.

Now

'201':
  description: ''
  content:
    application/json:
      schema:
        type: object
        #example: ...
        properties:
          this:
            type: string
            example: shouldn't be ignored
          and this:
            type: string
            example: too
            description: Parameter description, ha!
          sub level 0:
            type: object
            properties:
              sub level 1 key 1:
                type: string
                example: sl0_sl1k1
              sub level 1 key 2:
                type: array
                example:
                - sub level 2 key 1: sl0_sl1k2_sl2k1
                  sub level 2 key 2:
                    sub level 3 key 1: sl0_sl1k2_sl2k2_sl3k1
                items:
                  type: object
              sub level 1 key 3:
                type: object
                properties:
                  sub level 2 key 1:
                    type: string
                    example: sl0_sl1k3_sl2k2
                    description: This is description of nested object
                  sub level 2 key 2:
                    type: object
                    properties:
                      sub level 3 key 1:
                        type: string
                        example: sl0_sl1k3_sl2k2_sl3k1
                      sub level 3 key null:
                        type: string
                        example:
                      sub level 3 key integer:
                        type: integer
                        example: 99
'204':
  description: Successfully updated.

@shalvah shalvah merged commit d341570 into knuckleswtf:master Dec 13, 2022
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