Skip to content

Commit

Permalink
Revert to using x-ms-azure-resource extension rather than path heuris…
Browse files Browse the repository at this point in the history
…tics to identify read-only resources
  • Loading branch information
jeskew committed May 27, 2022
1 parent f80bcf2 commit 0e3d296
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/autorest.bicep/src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,6 @@ export function getProviderDefinitions(codeModel: CodeModel, host: AutorestExten
}
});

// This plugin determines what resources are defined in a given ARM swagger definition via the following three
// heuristics:
// 1. If a path uses the PUT HTTP method, it represents an addressable resource that may be created and updated.
// 2. If a path uses the GET HTTP method whose response schema uses the `x-ms-azure-resource` Swagger extension,
// it represents an addressable resource that may be read.
// 3. If a path uses the GET HTTP *and* ends in a path parameter, it most likely represents an addressable
// resource that may be read.
const resourcesByProvider: Dictionary<ResourceDefinition[]> = {};
for (const lcPath of new Set<string>([...Object.keys(putOperationsByPath), ...Object.keys(getOperationsByPath)])) {
const putOperation = putOperationsByPath[lcPath];
Expand All @@ -266,12 +259,9 @@ export function getProviderDefinitions(codeModel: CodeModel, host: AutorestExten
);
} else if (getData && isResourceSchema(getData.responseSchema)) {
parseResult = parseResourceMethod(getData.request.path, getData.parameters, apiVersion, true, false);
} else if (getData && parseResourceTypes(getData.parameters, getData.request.path).success) {
logWarning(`Assuming ${lcPath} is a resource due to the path pattern used. Response definition is missing`
+ " the `x-ms-azure-resource` Swagger extension.");
parseResult = parseResourceMethod(getData.request.path, getData.parameters, apiVersion, true, false);
} else {
// A non-resource get with no corresponding put is most likely a list endpoint
// A non-resource get with no corresponding put is most likely a collection or utility endpoint.
// No types should be generated
continue;
}

Expand Down

0 comments on commit 0e3d296

Please sign in to comment.