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

Allow referencing component schemas in component schemas #727

Merged
merged 7 commits into from
Apr 8, 2021
Merged

Allow referencing component schemas in component schemas #727

merged 7 commits into from
Apr 8, 2021

Conversation

glatzert
Copy link
Contributor

@glatzert glatzert commented Apr 7, 2021

Description of the Change

I added a cmdlet New-PodeOASchemaProperty which allows to create $refs to component schemas.

Related Issue

No related issue, I'm doing unsolicited PRs again - sorry.

Examples

Can be used like this:

Add-PodeOAComponentSchema -Name "ManagedOrganizationUnitConfiguration" -Schema (
    New-PodeOAObjectProperty -Properties @(
        (New-PodeOABoolProperty -Name "AllowBatchCreation"),
        (New-PodeOABoolProperty -Name "CheckForDuplicates"),
    ));

Add-PodeOAComponentSchema -Name "ManagedOrganizationalUnitsResponse" -Schema (
    New-PodeOAObjectProperty -Properties @(
        (New-PodeOAStringProperty -Name "Uuid" -Required),
        (New-PodeOAStringProperty -Name "Name" -Required),
        (New-PodeOASchemaProperty -Name "Config" -Reference "ManagedOrganizationUnitConfiguration")
    ));

Additional Context

I'm not completely sure about my changes in /private/OpenApi.ps1, but my swagger file looked correct (just a small excerpt):

"ManagedOrganizationalUnitsResponse": {
  "properties": {
    "Uuid": {
      "type": "string",
      "format": ""
    },
    "Name": {
      "type": "string",
      "format": ""
    },
    "Config": {
      "$ref": "#/components/schemas/ManagedOrganizationUnitConfiguration"
    },
}

@Badgerati
Copy link
Owner

I'm doing unsolicited PRs again - sorry

Hahah, it's all right! 😄

src/Public/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Public/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Public/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Public/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Private/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Private/OpenApi.ps1 Outdated Show resolved Hide resolved
src/Public/OpenApi.ps1 Outdated Show resolved Hide resolved
@Badgerati Badgerati added this to the 2.2.2 milestone Apr 8, 2021
Copy link
Owner

@Badgerati Badgerati left a comment

Choose a reason for hiding this comment

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

LGTM! :D

@Badgerati Badgerati merged commit 43d2d5f into Badgerati:develop Apr 8, 2021
@Badgerati Badgerati mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants