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

Generate a Microsoft Graph SDK #4346

Merged
merged 117 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
b5e5547
importer-msgraph-metadata: correct casing for constant names
manicminer Jul 25, 2024
19178fc
generator-go-sdk: support generating Common Types and a Microsoft Gra…
manicminer Jul 25, 2024
013a475
importer-msgraph-metadata: set correct response model for list operat…
manicminer Jul 29, 2024
cf46891
data-api-repository: support `ReferenceNameIsCommonType` for object d…
manicminer Jul 29, 2024
eb707ce
generator-go-sdk: use the value of `ReferenceNameIsCommonType` instea…
manicminer Jul 29, 2024
4d00699
data-api-sdk: oops, resource manager is not data plan (and vice versa)
manicminer Jul 30, 2024
d49c26f
importer-msgraph-metadata: prefix constant key names with underscore,…
manicminer Jul 30, 2024
48e4599
importer-msgraph-metadata: blacklist some resources
manicminer Jul 30, 2024
f1dfce0
importer-msgraph-metadata: fix openapi file pattern for list-tags com…
manicminer Jul 30, 2024
589ea90
generator-go-sdk: try to appease apparent golang race condition with …
manicminer Jul 30, 2024
98d0e96
generator-go-sdk: fix up remaining package references for common mode…
manicminer Jul 30, 2024
cfaff14
msgraph: import more services, attain feature parity (and much more) …
manicminer Jul 30, 2024
755f766
importer-msgraph-metadata: trim leading word from resource names when…
manicminer Jul 30, 2024
43b5f4a
importer-msgraph-metadata: blacklist OneNote resources in the Users s…
manicminer Jul 30, 2024
3e96ea0
importer-msgraph-metadata: remove the "ById" resource/operation suffix
manicminer Jul 30, 2024
8f528c4
importer-msgraph-metadata: bump tool version
manicminer Jul 30, 2024
85c3bad
importer-msgraph-metadata: trim leading word from operation names whe…
manicminer Jul 30, 2024
449383d
importer-msgraph-metadata: blacklist more services due to inscrutable…
manicminer Jul 30, 2024
d174e89
importer-msgraph-metadata: fix blacklist to compare the category rath…
manicminer Jul 30, 2024
e1472e9
importer-msgraph-metadata: write initial documentation
manicminer Jul 30, 2024
5f0d526
generator-go-sdk: set the correct package for the base client
manicminer Jul 30, 2024
9b4b665
generator-go-sdk: reusable constructor for base clients
manicminer Jul 30, 2024
1ff7cc3
importer-msgraph-metadata: support resource IDs as common types
manicminer Aug 1, 2024
ce35d29
generator-go-sdk: support resource IDs as common types, fix race cond…
manicminer Aug 1, 2024
9490e9e
importer-msgraph-metadata: improve service translation, ensure Refere…
manicminer Aug 2, 2024
e23cfda
data-api: support for native odata options
manicminer Aug 3, 2024
ee6fb32
importer-msgraph-metadata: handle bad models by ignoring them, suppor…
manicminer Aug 3, 2024
0e8e9a9
generator-go-sdk: support for generating odata options
manicminer Aug 3, 2024
37645a2
update to latest msgraph-metadata
manicminer Aug 4, 2024
39e9fec
importer-msgraph-metadata: fix singularization rules to avoid collisi…
manicminer Aug 5, 2024
3b1c2d6
importer-msgraph-metadata: singularization fix for "access", casing f…
manicminer Aug 5, 2024
5d1ba6f
generator-go-sdk: add missing imports
manicminer Aug 5, 2024
53758b6
generator-go-sdk: fix package/directory name for API version when out…
manicminer Aug 5, 2024
066c7ab
generator-go-sdk: unit test updates
manicminer Aug 5, 2024
c39cc5c
generator-go-sdk: fix meta client package naming for numerically vers…
manicminer Aug 5, 2024
8855269
generator-go-sdk: fix output path for resource packages
manicminer Aug 5, 2024
7467e1d
importer-msgraph-metadata: rename file
manicminer Aug 6, 2024
78cba7b
generator-go-sdk: more API version name/directory fixes
manicminer Aug 6, 2024
569b3ca
importer-msgraph-metadata: more renames
manicminer Aug 6, 2024
e8a1d3b
data-api: add a `nullable` option for data types
manicminer Aug 11, 2024
c6b5c01
generator-go-sdk: support for generating models with fields having nu…
manicminer Aug 11, 2024
da2d563
importer-msgraph-metadata: support for nullable field types
manicminer Aug 11, 2024
8584a9e
importer-msgraph-metadata: add an explicit `ODataId` field to every m…
manicminer Aug 11, 2024
76465fe
generator-go-sdk: log gofmt/goimports invocations
manicminer Aug 12, 2024
a7efc77
importer-msgraph-metadata: add an `@odata.bind` field for referenced …
manicminer Aug 12, 2024
63b5705
importer-msgraph-metadata: add data workaround for missing fields in …
manicminer Aug 12, 2024
5b4b818
generator-go-sdk: support unmarshaling discriminated types directly f…
manicminer Aug 14, 2024
b44f8e3
importer-msgraph-metadata: support for discriminated types
manicminer Aug 14, 2024
c611623
importer-msgraph-metadata: workaround for making NamedLocation a disc…
manicminer Aug 14, 2024
585af0c
importer-msgraph-metadata: manual casing fixes for `Ip` => `IP` and `…
manicminer Aug 14, 2024
c3a1f02
generator-go-sdk: export the `Unmarshal{Name}Implementation` function…
manicminer Aug 14, 2024
7f663b6
importer-msgraph-metadata: fix bug that generated constant fields wit…
manicminer Aug 14, 2024
3d03964
importer-msgraph-metadata: singularize constant names
manicminer Aug 14, 2024
d66faac
generator-go-sdk: support Required + Nullable model fields, and gener…
manicminer Aug 14, 2024
7b608bd
importer-msgraph-metadata: improve name deuplication helper function,…
manicminer Aug 14, 2024
77de1be
importer-msgraph-metadata: use `github.com/gertd/go-pluralize` for pl…
manicminer Aug 14, 2024
b56cb17
importer-msgraph-metadata: improve constant naming
manicminer Aug 14, 2024
e197f77
importer-msgraph-metadata: workarounds for conditional access
manicminer Aug 14, 2024
15ddd29
importer-msgraph-metadata: more workaround for conditional access
manicminer Aug 15, 2024
7432097
generator-go-sdk: test fixes
manicminer Aug 15, 2024
4a63959
importer-msgraph-metadata: add support for DirectoryRoles
manicminer Aug 15, 2024
b6b96b3
importer-msgraph-metadata: add support for DirectoryRoleTemplates
manicminer Aug 15, 2024
e884bf6
generator-go-sdk: improvements to discriminated model types
manicminer Aug 16, 2024
d79b5b9
importer-msgraph-metadata: output unknown array member types as `[]in…
manicminer Aug 17, 2024
70694a3
importer-msgraph-metadata: remove prefix from actions in URL segments
manicminer Aug 17, 2024
23b4899
generator-go-sdk: handle ReadOnly fields by omitting them when marsha…
manicminer Aug 17, 2024
f55f7ad
importer-msgraph-metadata: workaround for common read-only fields
manicminer Aug 17, 2024
48e59a1
importer-msgraph-metadata: workaround to implement discrimination for…
manicminer Aug 17, 2024
d559a59
importer-msgraph-metadata: clean up field description for OData Bind …
manicminer Aug 17, 2024
91b5eb0
data-api: support descriptions for operations
manicminer Aug 18, 2024
90ccc10
generator-go-sdk: use operation descriptions to output method comments
manicminer Aug 18, 2024
5311455
importer-msgraph-metadata: set descriptions for operations
manicminer Aug 18, 2024
a23cef6
importer-msgraph-metadata: clean up operation descriptions
manicminer Aug 18, 2024
de9120a
generator-go-sdk: sort read-only fields for consistency
manicminer Aug 18, 2024
e0f4e9a
generator-go-sdk: should use the actual json field name when working …
manicminer Aug 18, 2024
1b7c65e
importer-msgraph-metadata: use `interface{}` not `string` for unknown…
manicminer Aug 18, 2024
f082d47
importer-msgraph-metadata: detect nullable, read-only and required fi…
manicminer Aug 18, 2024
a06fc9a
importer-msgraph-metadata: extra safety when assumung nullable fields…
manicminer Aug 18, 2024
85d0398
generator-go-sdk: bugfix - escape formatting directive
manicminer Aug 18, 2024
789b1b3
generator-go-sdk: wrap comment lines for model fields
manicminer Aug 18, 2024
906cf84
tooling: split end-to-end tests by SDK for easier analysis
manicminer Aug 18, 2024
6f3f1a5
generator-go-sdk: populate inherited model struct fields from all par…
manicminer Aug 19, 2024
70799a5
tooling: adjust workflow triggers to only run when necessary
manicminer Aug 19, 2024
b53beb0
tooling: run `go mod tidy` prior to running unit tests after generation
manicminer Aug 19, 2024
1c71b9c
importer-msgraph-metadata: support Resource IDs in data workarounds
manicminer Aug 19, 2024
32c9c99
importer-msgraph-metadata: add workaround for invalid resource IDs no…
manicminer Aug 19, 2024
127b0cb
generator-go-sdk: linting for method comments
manicminer Aug 22, 2024
0b2f7cd
importer-msgraph-metadata: refactor model parser, various improvements
manicminer Aug 22, 2024
99867f6
importer-msgraph-metadata: explicitly flag parent models at import ti…
manicminer Sep 4, 2024
23fa804
generator-go-sdk: support for parsing and generating extended model a…
manicminer Sep 4, 2024
5e92c96
importer-msgraph-metadata: new! improved! method naming
manicminer Sep 4, 2024
230f9a9
generator-go-sdk: update test fixtures
manicminer Sep 4, 2024
7a2417e
importer-msgraph-metadata: fix clobbering bug in method names for del…
manicminer Sep 4, 2024
bd2b9e8
generator-go-sdk: `Base{Model}Impl` structs should implement their ow…
manicminer Sep 4, 2024
483014a
importer-msgraph-metadata: ensure leading service name is trimmed fro…
manicminer Sep 5, 2024
ff34b34
generator-go-sdk: update test fixtures
manicminer Sep 5, 2024
6cef487
importer-msgraph-metadata: add service workaround to add missing GET …
manicminer Sep 5, 2024
e1126b9
importer-msgraph-metadata: fix up response model for synchronization …
manicminer Sep 6, 2024
962737c
importer-msgraph-metadata: add some more verbs found in `user` package
manicminer Sep 6, 2024
e67b869
importer-msgraph-metadata: fix singularization & verb handling bugs, …
manicminer Sep 6, 2024
d919e46
importer-msgraph-metadata: more pluralization and verb exceptions
manicminer Sep 9, 2024
06c4a09
importer-msgraph-metadata: deduplicate resource (category) and operat…
manicminer Sep 9, 2024
f6c4a6d
importer-msgraph-metadata: extend synchronizationsecret workaround to…
manicminer Sep 9, 2024
9638974
data-api: support importer-specified example values for userspecified…
manicminer Sep 12, 2024
25807be
generator-go-sdk: fix up struct tag for nullable model fields
manicminer Sep 12, 2024
f1fbe24
generator-go-sdk: update readme generator to be sourceDataType-aware
manicminer Sep 12, 2024
ba9c327
generator-go-sdk: ensure all ancestor fields are unmarshalled for dis…
manicminer Sep 12, 2024
c45f730
importer-msgraph-metadata: set a reasonable example value for user sp…
manicminer Sep 12, 2024
6f698c0
importer-msgraph-metadata: fix early exit bug in SynchronizationSecre…
manicminer Sep 12, 2024
9260ca5
importer-msgraph-metadata: disable deduplication for categories, once…
manicminer Sep 12, 2024
8e09d5c
importer-msgraph-metadata: add unit test for `TruncateToLastSegmentOf…
manicminer Sep 12, 2024
51de4a5
importer-msgraph-metadata: add unit test for `FullyQualifiedResourceN…
manicminer Sep 12, 2024
63aa605
importer-msgraph-metadata: support OData Metadata parameter
manicminer Sep 12, 2024
b65699e
generator-go-sdk: fix bug in parent model check
manicminer Sep 13, 2024
b494190
generator-go-sdk: update test
manicminer Sep 13, 2024
b3a0bd9
config: adding `beta` API for `identityGovernance` in `microsoft-graph`
manicminer Sep 16, 2024
743c42a
importer-msgraph-metadata: add more doc comments, remove resource bla…
manicminer Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- fake_name_to_disable_trigger
paths:
- '.github/workflows/**'
- 'config/microsoft-graph.hcl'
- 'submodules/msgraph-metadata'
- 'tools/importer-msgraph/**'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/automation-regenerate-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches:
- main
paths:
- 'api-definitions/**'
- 'api-definitions/handwritten-resource-manager/**'
- 'api-definitions/resource-manager/**'
- 'tools/generator-terraform/**'
workflow_dispatch: # for manual invocations

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automation-rest-api-specs-importer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
branches:
- main
paths:
- '.github/workflows/**'
- 'config/**'
- 'config/resource-manager.hcl'
- 'config/resources/**'
- 'submodules/rest-api-specs'
- 'tools/importer-rest-api-specs/**'
workflow_dispatch: # for manual invocations
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automation-version-bumper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
branches:
- main
paths:
- '.github/workflows/**'
- 'config/**'
- '.github/workflows/automation-version-bumper.yaml'
- 'config/resource-manager.hcl'
- 'submodules/msgraph-metadata'
- 'submodules/rest-api-specs'
- 'tools/version-bumper/**'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-data-api-differ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- '.github/workflows/unit-test-data-api-differ.yaml'
- 'tools/data-api-differ/**'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-data-api-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- '.github/workflows/unit-test-data-api-v2.yaml'
- 'api-definitions/**'
- 'tools/data-api/**'

Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/unit-test-end-to-end-microsoft-graph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Verify All Microsoft Graph Services can be Imported and Generated
on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/unit-test-end-to-end-microsoft-graph.yaml'
- 'config/microsoft-graph.hcl'
- 'tools/generator-go-sdk/**'
- 'tools/importer-msgraph-metadata/**'

jobs:
test:
runs-on: custom-linux-xl
strategy:
fail-fast: true
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: recursive

- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: ./.go-version

- name: "Build and Run importer-msgraph-metadata"
id: import-data
run: |
cd ./tools/importer-msgraph-metadata
make tools
make build
make import

- name: "Run the Go SDK Generator"
run: |
# go go gadget generator
./scripts/automation-generate-go-sdk.sh microsoft-graph
9 changes: 6 additions & 3 deletions .github/workflows/unit-test-end-to-end-resource-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- 'config/**'
- '.github/workflows/unit-test-end-to-end-resource-manager.yaml'
- 'config/resource-manager.hcl'
- 'config/resources/**'
- 'tools/generator-go-sdk/**'
- 'tools/importer-rest-api-specs/**'

jobs:
test:
Expand All @@ -32,4 +35,4 @@ jobs:
- name: "Run the Go SDK Generator"
run: |
# go go gadget generator
./scripts/automation-generate-go-sdk.sh
./scripts/automation-generate-go-sdk.sh resource-manager
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-generator-go-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- '.github/workflows/unit-test-generator-go-sdk.yaml'
- 'tools/generator-go-sdk/**'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-generator-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- '.github/workflows/unit-test-generator-terraform.yaml'
- 'tools/generator-terraform/**'

jobs:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/unit-test-rest-api-specs-importer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- 'config/**'
- '.github/workflows/unit-test-rest-api-specs-importer.yaml'
- 'config/resource-manager.hcl'
- 'config/resources/**'
- 'submodules/rest-api-specs'
- 'tools/importer-rest-api-specs/**'

Expand Down
35 changes: 35 additions & 0 deletions config/microsoft-graph.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ service "applicationTemplates" {
available = ["stable", "beta"]
}

service "auditLogs" {
name = "AuditLogs"
available = ["stable", "beta"]
}

service "deviceManagement" {
name = "DeviceManagement"
available = ["stable", "beta"]
}

service "directory" {
name = "Directory"
available = ["stable", "beta"]
Expand All @@ -31,6 +41,16 @@ service "directoryObjects" {
available = ["stable", "beta"]
}

service "directoryRoles" {
name = "DirectoryRoles"
available = ["stable", "beta"]
}

service "directoryRoleTemplates" {
name = "DirectoryRoleTemplates"
available = ["stable", "beta"]
}

service "domains" {
name = "Domains"
available = ["stable", "beta"]
Expand All @@ -46,6 +66,11 @@ service "identity" {
available = ["stable"]
}

service "identityGovernance" {
name = "IdentityGovernance"
available = ["stable", "beta"]
}

service "invitations" {
name = "Invitations"
available = ["stable", "beta"]
Expand All @@ -66,11 +91,21 @@ service "policies" {
available = ["stable", "beta"]
}

service "reports" {
name = "Reports"
available = ["stable", "beta"]
}

service "roleManagement" {
name = "RoleManagement"
available = ["stable", "beta"]
}

service "schemaExtensions" {
name = "SchemaExtensions"
available = ["stable", "beta"]
}

service "servicePrincipals" {
name = "ServicePrincipals"
available = ["stable", "beta"]
Expand Down
32 changes: 20 additions & 12 deletions scripts/automation-generate-go-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ set -e

DIR="$(cd "$(dirname "$0")" && pwd)/.."

sdkToGenerate="${1}"
if [[ "${sdkToGenerate}" == "" ]]; then
echo "must specify SDK to generate!" >&2
echo "" >&2
echo "supported values are:" >&2
echo " microsoft-graph" >&2
echo " resource-manager" >&2
echo "" >&2
echo "example usage:" >&2
echo "${0} resource-manager" >&2
exit 1
fi

function buildAndInstallDependencies {
echo "Outputting Go Version.."
go version
Expand All @@ -31,15 +44,9 @@ function runWrapper {
local apiDefinitionsDirectory=$1
local outputDirectory=$2

echo "Running Wrapper for Resource Manager.."
cd "${DIR}/tools/wrapper-automation"
./wrapper-automation resource-manager go-sdk \
--api-definitions-dir="../../$apiDefinitionsDirectory"\
--output-dir="../../$outputDirectory"

echo "Running Wrapper for Microsoft Graph.."
echo "Running Wrapper for ${sdkToGenerate}.."
cd "${DIR}/tools/wrapper-automation"
./wrapper-automation microsoft-graph go-sdk \
./wrapper-automation "${sdkToGenerate}" go-sdk \
--api-definitions-dir="../../$apiDefinitionsDirectory"\
--output-dir="../../$outputDirectory"

Expand All @@ -61,11 +68,12 @@ function runWrapper {
function runGoSDKUnitTests {
local outputDirectory=$1

cd "${DIR}"
echo "Running unit tests within the SDK codebase.."
cd "${outputDirectory}/${sdkToGenerate}"
go mod tidy
go test -v ./...

echo "Running 'make test' within the SDK codebase.."
cd "${outputDirectory}"
make test
cd "${DIR}"
}

function prepareGoSdk {
Expand Down
2 changes: 1 addition & 1 deletion submodules/msgraph-metadata
2 changes: 1 addition & 1 deletion tools/data-api-differ/internal/differ/differ_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// stringifySDKObjectDefinition returns a human readable, string version of this SDKObjectDefinition.
func (d differ) stringifySDKObjectDefinition(input models.SDKObjectDefinition) (*string, error) {
return helpers.GolangTypeForSDKObjectDefinition(input, nil)
return helpers.GolangTypeForSDKObjectDefinition(input, nil, nil)
}

// stringifySDKOperationOptionObjectDefinition returns a human readable, string version of this Object Definition.
Expand Down
26 changes: 18 additions & 8 deletions tools/data-api-repository/repository/helpers_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ func parseCommonTypesWithin(workingDirectory string, logger hclog.Logger) (*map[
apiVersion = strings.TrimPrefix(apiVersion, "/")

commonTypes := sdkModels.CommonTypes{
Constants: map[string]sdkModels.SDKConstant{},
Models: map[string]sdkModels.SDKModel{},
Constants: map[string]sdkModels.SDKConstant{},
Models: map[string]sdkModels.SDKModel{},
ResourceIDs: make(map[string]sdkModels.ResourceID),
}

logger.Trace(fmt.Sprintf("Discovering the Common Type Constants within %q..", subDirectory))
Expand All @@ -75,7 +76,14 @@ func parseCommonTypesWithin(workingDirectory string, logger hclog.Logger) (*map[
}
commonTypes.Models = *models

if len(commonTypes.Constants) > 0 || len(commonTypes.Models) > 0 {
logger.Trace(fmt.Sprintf("Discovering the Common Type Resource IDs within %q..", subDirectory))
resourceIds, err := parseResourceIDsWithin(subDirectory, *constants, logger)
if err != nil {
return nil, fmt.Errorf("parsing the Common Type Models within %q: %+v", subDirectory, err)
}
commonTypes.ResourceIDs = *resourceIds

if len(commonTypes.Constants) > 0 || len(commonTypes.Models) > 0 || len(commonTypes.ResourceIDs) > 0 {
output[apiVersion] = commonTypes
}
}
Expand Down Expand Up @@ -183,15 +191,17 @@ func parseAPIResourceWithin(workingDirectory, resourceName string, commonTypesFo
}

knownData := helpers.KnownData{
Constants: *constants,
Models: *models,
ResourceIds: *resourceIds,
CommonTypeConstants: make(map[string]sdkModels.SDKConstant),
CommonTypeModels: make(map[string]sdkModels.SDKModel),
Constants: *constants,
Models: *models,
ResourceIds: *resourceIds,
CommonTypeConstants: make(map[string]sdkModels.SDKConstant),
CommonTypeModels: make(map[string]sdkModels.SDKModel),
CommonTypesResourceIds: make(map[string]sdkModels.ResourceID),
}
if commonTypesForThisAPIVersion != nil {
knownData.CommonTypeConstants = commonTypesForThisAPIVersion.Constants
knownData.CommonTypeModels = commonTypesForThisAPIVersion.Models
knownData.CommonTypesResourceIds = commonTypesForThisAPIVersion.ResourceIDs
}

logger.Trace(fmt.Sprintf("Parsing the Operations within %q..", workingDirectory))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ type KnownData struct {
Models map[string]sdkModels.SDKModel
ResourceIds map[string]sdkModels.ResourceID

CommonTypeConstants map[string]sdkModels.SDKConstant
CommonTypeModels map[string]sdkModels.SDKModel
CommonTypeConstants map[string]sdkModels.SDKConstant
CommonTypeModels map[string]sdkModels.SDKModel
CommonTypesResourceIds map[string]sdkModels.ResourceID
}

func (d KnownData) ConstantExists(constantName string) bool {
Expand All @@ -38,5 +39,6 @@ func (d KnownData) ModelExists(modelName string) bool {

func (d KnownData) ResourceIDExists(resourceIdName string) bool {
_, resourceIdExists := d.ResourceIds[resourceIdName]
return resourceIdExists
_, commonTypesResourceIdExists := d.CommonTypesResourceIds[resourceIdName]
return resourceIdExists || commonTypesResourceIdExists
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type Model struct {
// Fields is an array of fields contained in the Model
Fields []ModelField `json:"fields"`

// IsParent specifies whether this model is a known parent model, typically for discriminated child models.
IsParent bool

// NOTE: If DiscriminatedParentModelName and DiscriminatedTypeValue are both populated then this Model
// represents a discriminated type
// DiscriminatedParentModelName contains the name of the Parent Model that this Model would implement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ type ObjectDefinition struct {
// ObjectDefinitionType defines what kind of ObjectDefinition this is, such as a Reference, String or List
Type ObjectDefinitionType `json:"type"`

// NOTE: we could split this into ConstantName and ModelName in time, but not today.
// Nullable specifies that this type should be unset by sending `null` as the JSON value.
Nullable bool `json:"nullable"`

// ReferenceName is the name of the Constant or Model that this is a reference to
ReferenceName *string `json:"referenceName"`

// ReferenceNameIsCommonType indicates whether ReferenceName refers to a common type (true) or a type that is local to the service (false)
ReferenceNameIsCommonType *bool `json:"referenceNameIsCommonType"`

// NestedItem is a nested ObjectDefinition when Type is a Dictionary or List
// NOTE: that it's possible to have deeply-nested ObjectDefinitions, e.g. a List of a List of a Dictionary[String (key, fixed as a string) : Integer (value)
NestedItem *ObjectDefinition `json:"nestedItem,omitempty"`
Expand Down
Loading
Loading