Skip to content

Commit

Permalink
importer-msgraph-metadata: global fix for inconsistent HTTP status co…
Browse files Browse the repository at this point in the history
…des in responses

Additionally, internally, collapse `Responses: []Response` into the
`Operation` struct, to better model the Data API SDK types, as we
are only ever using a single `Response`.
  • Loading branch information
manicminer committed Sep 24, 2024
1 parent f93bb90 commit cf04950
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 401 deletions.
33 changes: 14 additions & 19 deletions tools/importer-msgraph-metadata/components/parser/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type Operation struct {
// The remainder of the URI after the resource ID
UriSuffix *string

// When the content type is JSON or XML, and this is a List operation, the name of the field
// that specifies a URL to retrieve the next page of results
PaginationField *string

// The content-type of the request body
RequestContentType *string

Expand All @@ -71,35 +75,26 @@ type Operation struct {
// and the request is not described by a model
RequestType *DataType

// The expected *success* responses for this operation
Responses []Response

// When the content type is JSON or XML, and this is a List operation, the name of the field
// that specifies a URL to retrieve the next page of results
PaginationField *string

// OpenAPI3 tags for this operation, used to reconcile operations to services
Tags []string
}

type Response struct {
// The HTTP status code associated with this expected response
Status int
// The HTTP status codes associated with this expected response
ResponseStatusCodes []int

// The expected content type for this resource
ContentType *string
ResponseContentType *string

// Specifies a referenced model or constant for the response, noting that this
// should be the full type name from the spec prior to normalizing
ReferenceName *string
ResponseReferenceName *string

// The internal data type for the response, used when the content type is JSON or XML,
// and the response is not described by a model
Type *DataType
ResponseType *DataType

// Model and Constant are used internally for ad-hoc response models
Model *Model
Constant *Constant
ResponseModel *Model
ResponseConstant *Constant

// OpenAPI3 tags for this operation, used to reconcile operations to services
Tags []string
}

type Header struct {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,18 @@ func (workaroundSynchronizationSecrets) Process(apiVersion, serviceName string,
}

resource.Operations = append(resource.Operations, parser.Operation{
Name: "ListSynchronizationSecrets",
Description: "Retrieve synchronization secrets.",
Type: parser.OperationTypeList,
Method: http.MethodGet,
PaginationField: pointer.To("@odata.nextLink"),
ResourceId: resourceId,
UriSuffix: uriSuffix,
Responses: []parser.Response{
{
Status: http.StatusOK,
ContentType: pointer.To("application/json"),
ReferenceName: pointer.To("microsoft.graph.synchronizationSecretKeyStringValuePair"),
Type: pointer.To(parser.DataTypeReference),
},
},
Tags: tags,
Name: "ListSynchronizationSecrets",
Description: "Retrieve synchronization secrets.",
Type: parser.OperationTypeList,
Method: http.MethodGet,
PaginationField: pointer.To("@odata.nextLink"),
ResourceId: resourceId,
UriSuffix: uriSuffix,
ResponseStatusCodes: []int{http.StatusOK},
ResponseContentType: pointer.To("application/json"),
ResponseReferenceName: pointer.To("microsoft.graph.synchronizationSecretKeyStringValuePair"),
ResponseType: pointer.To(parser.DataTypeReference),
Tags: tags,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ var serviceWorkarounds = []serviceWorkaround{
workaroundBlacklist{},

// Service-specific workarounds
workaroundApplicationTemplates{},
workaroundEntitlementManagementAccessPackageAccessPackageResourceRoleScope{},
workaroundEntitlementManagementRoleAssignment{},
workaroundGroups{},
workaroundSynchronizationSecrets{},
}

Expand Down
Loading

0 comments on commit cf04950

Please sign in to comment.