Skip to content

Commit

Permalink
Add ODataId to required properties for update and create. (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
peombwa authored Apr 26, 2023
1 parent a49fed5 commit b254ebe
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Describe "Update-MgBetaApplication" {
}

It "Should support UpdateExpanded parameterSet by default" {
$UpdateMgBetaApplication.OutputType | Should -Be "System.Boolean"
$UpdateMgBetaApplication.OutputType | Should -Be "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphApplication"
$UpdateMgBetaApplication.DefaultParameterSet | Should -Be "UpdateExpanded"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Describe "New-MgApplicationOwnerByRef" {
$CreateExpandedParameterSet.Parameters.Name | Should -Contain OdataId
$CreateExpandedParameterSet.Parameters.Name | Should -Contain AdditionalProperties
$CreateExpandedParameterSet.Parameters.Name | Should -Not -Contain BodyParameter
$NewMgApplicationOwnerByRef.Parameters.OdataId.ParameterSets.CreateExpanded.IsMandatory | Should -be $true
}

It 'Should have Create parameterSet' {
Expand All @@ -45,5 +46,6 @@ Describe "New-MgApplicationOwnerByRef" {
$CreateViaIdentityExpandedParameterSet.Parameters.Name | Should -Contain OdataId
$CreateViaIdentityExpandedParameterSet.Parameters.Name | Should -Contain AdditionalProperties
$CreateViaIdentityExpandedParameterSet.Parameters.Name | Should -Not -Contain BodyParameter
$NewMgApplicationOwnerByRef.Parameters.OdataId.ParameterSets.CreateViaIdentityExpanded.IsMandatory | Should -be $true
}
}
2 changes: 1 addition & 1 deletion src/Applications/v1.0/test/Update-MgApplication.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Describe "Update-MgApplication" {
}

It "Should support UpdateExpanded parameterSet by default" {
$UpdateMgApplication.OutputType | Should -Be "System.Boolean"
$UpdateMgApplication.OutputType | Should -Be "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphApplication"
$UpdateMgApplication.DefaultParameterSet | Should -Be "UpdateExpanded"
}

Expand Down
51 changes: 51 additions & 0 deletions src/Users/v1.0/test/Set-MgUserManagerByRef.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
Describe "Set-MgUserManagerByRef" {
BeforeAll {
$SetMgUserManagerByRef = Get-Command Set-MgUserManagerByRef
}

It "Should support minimum set of parameter sets" {
$SetMgUserManagerByRef.ParameterSets.Name | Should -BeIn @("Set", "SetExpanded", "SetViaIdentity", "SetViaIdentityExpanded")
$SetMgUserManagerByRef.Visibility | Should -Be "Public"
$SetMgUserManagerByRef.CommandType | Should -Be "Function"
}

It "Should support SetExpanded parameterSet by default" {
$SetMgUserManagerByRef.OutputType | Should -Be "System.Boolean"
$SetMgUserManagerByRef.DefaultParameterSet | Should -Be "SetExpanded"
}

It 'Should have SetExpanded parameterSet' {
$SetExpandedParameterSet = $SetMgUserManagerByRef.ParameterSets | Where-Object Name -eq "SetExpanded"
$SetExpandedParameterSet.Parameters.Name | Should -Contain UserId
$SetExpandedParameterSet.Parameters.Name | Should -Contain OdataId
$SetExpandedParameterSet.Parameters.Name | Should -Contain AdditionalProperties
$SetExpandedParameterSet.Parameters.Name | Should -Not -Contain BodyParameter
$SetMgUserManagerByRef.Parameters.OdataId.ParameterSets.SetExpanded.IsMandatory | Should -be $true
}

It 'Should have Set parameterSet' {
$SetParameterSet = $SetMgUserManagerByRef.ParameterSets | Where-Object Name -eq "Set"
$SetParameterSet.Parameters.Name | Should -Contain UserId
$SetParameterSet.Parameters.Name | Should -Contain BodyParameter
$SetParameterSet.Parameters.Name | Should -Not -Contain AdditionalProperties
}

It 'Should have SetViaIdentity parameterSet' {
$SetViaIdentityParameterSet = $SetMgUserManagerByRef.ParameterSets | Where-Object Name -eq "SetViaIdentity"
$SetViaIdentityParameterSet.Parameters.Name | Should -Contain InputObject
$SetViaIdentityParameterSet.Parameters.Name | Should -Contain BodyParameter
$SetViaIdentityParameterSet.Parameters.Name | Should -Not -Contain AdditionalProperties
}

It 'Should have SetViaIdentityExpanded parameterSet' {
$SetViaIdentityExpandedParameterSet = $SetMgUserManagerByRef.ParameterSets | Where-Object Name -eq "SetViaIdentityExpanded"
$SetViaIdentityExpandedParameterSet.Parameters.Name | Should -Contain InputObject
$SetViaIdentityExpandedParameterSet.Parameters.Name | Should -Contain OdataId
$SetViaIdentityExpandedParameterSet.Parameters.Name | Should -Contain AdditionalProperties
$SetViaIdentityExpandedParameterSet.Parameters.Name | Should -Not -Contain BodyParameter
$SetMgUserManagerByRef.Parameters.OdataId.ParameterSets.SetViaIdentityExpanded.IsMandatory | Should -be $true
}
}
13 changes: 13 additions & 0 deletions src/readme.graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,19 @@ directive:
}
}
}
# Mark '@odata.id' as required properties for /$ref.
- from: 'openapi-document'
where: $.components.schemas.ReferenceCreate
transform: $['required'] = ['@odata.id']
- from: 'openapi-document'
where: $.components.schemas.ReferenceCreate..properties['@odata.id']
transform: $['description'] = 'The entity reference URL of the resource. For example, https://graph.microsoft.com/v1.0/directoryObjects/{id}.'
- from: 'openapi-document'
where: $.components.schemas.ReferenceUpdate
transform: $['required'] = ['@odata.id']
- from: 'openapi-document'
where: $.components.schemas.ReferenceUpdate..properties['@odata.id']
transform: $['description'] = 'The entity reference URL of the resource. For example, https://graph.microsoft.com/v1.0/directoryObjects/{id}.'
# Mark consistency level parameter as required for /$count paths when header is present.
- from: openapi-document
where: $..paths.*[?(/(.*_GetCount)/gmi.exec(@.operationId))]..parameters[?(@.name === "ConsistencyLevel")]
Expand Down

0 comments on commit b254ebe

Please sign in to comment.