API spec cleanup and Go client regeneration#54
Open
hdm wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Top-to-bottom cleanup of
runzero-api.yml(the OpenAPI 3.0 source of truth) and a full regeneration of the Go SDK in./gousingopenapi-generatorv7.22.0. The result is a clean spec that codegens to an idiomatic Go client with no duplicate declarations and stable, descriptive type names.Spec changes (
runzero-api.yml)Type / naming deconfliction
Renamed schemas that collided with generator-emitted type names or that were ambiguous:
StatusMessage(schema) →OperationStatusSearch→SearchQueryAPIClient→APIClientCredentialsAPIKey(schema) →OrganizationAPIKeyNewCustomIntegration→CustomIntegrationCreateExtracted 14+ inline
oneOf/ anonymous 200-response shapes into named, stable component schemas (e.g.AssetPage,AssetExportResponse,ServicePage,ImportTask, etc.) so generated Go types no longer carry operation-name-derived suffixes likeExportAssetsJSON200ResponseOneOf.Correctness fixes
BaseResponseswitched to snake_case (client_id,created_at,created_by_id,updated_at,destroyed_at) to match server output — previously camelCase would silently zero-value real responses.type: string, format: binary(previously some advertised aCertificateobject orEventarray).pattern:constraints that the Go generator double-escaped into invalidvalidate:tags (e.g.BaseCustomIntegration.name,NetworkInterface.macAddress).Explorer/ExplorerPatchedSettingsaliases; the relevant ops now referenceAgent/AgentPatchedSettingsdirectly.OrgOptions.expiration_*switched from invented formats to plaintype: stringwith descriptions.x-go-type/x-go-importvendor extensions and trailing whitespace.Tag hygiene
getOrgCustomIntegration[s]fromOrg→Organization.exportAssetMetricsJSONasExport.importCustomIntegrationAssetsso each op ends up in exactly one API service file (avoids duplicate Go declarations).Final structural QA pass
requestBody.required: trueto 5 PUT ops that mandate a body:importScanData,importNessusScanData,importPacketData,createScan,createSample.Credential.typeenum from 9 to all 27 values, matchingCredentialOptions.type.text/json→application/jsononcreateScanandcreateSample.Audit results
operationIds, no duplicates$refs resolveGo client (
./go)openapi-generator -g go.openapi→runzero.github.com/runZeroInc/runzero-api; generator'sgo.mod/go.sumare removed after each regen (the repo's rootgo.modcovers./go).api_account.go,api_cisco_sntc.go,api_export.go,api_import.go,api_organization.go,api_public.go,api_service_now.go,api_splunk.go.model_asset_page.go,model_asset_export_response.go,model_import_task.go,model_search_query.go,model_operation_status.go,model_api_client_credentials.go,model_organization_api_key.go,model_custom_integration_create.go, the variousmodel_*_credential_fields.go, etc.).Examples
go/runzero-client/examples/basic/main.goandgo/runzero-client/examples/scan-all-sites/main.goupdated for the newPublicAPI/OrganizationAPIfield names.https://console.runzero.com/api/v1.0— returns Agent / Scanner / Platform versions.Tests
go/test/usepackage runzeroand importgithub.com/runZeroInc/runzero-api/go.go test ./go/...→ok github.com/runZeroInc/runzero-api/go/test.Verification
Notes (intentional, not blockers)
ImportAssetschema is retained as documentation for the binaryassetDataupload body format even though no op$refs it directly.DELETE /account/assets/ownership-typescarries a body (uncommon but valid for this bulk endpoint).303only — intentional redirects to S3.