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] Add "type" property with value "object" response schema to fix Infragistics AppBuilder tooling #2283

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

seantleonard
Copy link
Contributor

Why make this change?

Background

I found a relevant thread that discusses whether type is a required property. Consensus is that type isn't required:

OAI/OpenAPI-Specification#1657
OpenAPI-Specification discussion
PaloAltoNetworks/docusaurus-openapi-docs#430
Example of how different tooling handles type or missing type differently.
Ultimately, different tooling handles the presence of the type property differently. Some may try to guess the type when not present:

The fact that the type isn't required means that https://github.com/microsoft/OpenAPI.NET didn't complain about missing type. An error if type were required would have helped prevent this becoming an issue in the first place.

What is this change?

  • Adds "type": "object" to the openapi document for describing the response schema:
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object", // <--- This property/value
                                    "properties": {
                                        "value": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Book"
                                            }
                                        },
                                        "nextLink": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

View generated schema at

GET localhost:5001/api/openapi

Copy link
Contributor

@abhishekkumams abhishekkumams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change and adding relevant information on the PR description. It was easy to follow.

@abhishekkumams
Copy link
Contributor

/azp run

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aniruddh25 Aniruddh25 merged commit 591d818 into main Jul 3, 2024
7 checks passed
@Aniruddh25 Aniruddh25 deleted the dev/sean/openapi_typeproperty_2212 branch July 3, 2024 20:51
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.

Support for OpenAPI description in a Infragistics AppBuilder integration use case
3 participants