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

no-response-body rule is triggering for some standard templates #1740

Merged
merged 28 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fa121d3
no-response-body rule changed for arm
AlitzelMendez Oct 22, 2024
6550b85
Merge branch 'main' into no-response-body-rule
AlitzelMendez Oct 22, 2024
7d6bcb2
Add summary of changes
AlitzelMendez Oct 22, 2024
acec694
make summary changes more clear
AlitzelMendez Oct 24, 2024
b6d4e2e
fix typo
AlitzelMendez Oct 24, 2024
ebdb33c
include only azure subnamespace rule
AlitzelMendez Oct 24, 2024
bfaa0d7
fix test to specify right namespace
AlitzelMendez Oct 24, 2024
14720ad
Merge branch 'main' into no-response-body-rule
AlitzelMendez Oct 24, 2024
0df7f57
Merge branch 'main' into no-response-body-rule
AlitzelMendez Oct 25, 2024
2d418c9
Merge branch 'main' into no-response-body-rule
AlitzelMendez Oct 28, 2024
65df221
Feedback:
AlitzelMendez Oct 31, 2024
f2aaec1
Update docs/libraries/azure-resource-manager/rules/no-response-body.md
AlitzelMendez Oct 31, 2024
ea57a0e
Update docs/libraries/azure-resource-manager/rules/no-response-body.md
AlitzelMendez Oct 31, 2024
759893a
Add summary of changes
AlitzelMendez Oct 31, 2024
82e2545
Merge branch 'no-response-body-rule' of https://github.com/AlitzelMen…
AlitzelMendez Oct 31, 2024
65a0c34
Feedback: Removing condition, still pending fixing samples
AlitzelMendez Nov 4, 2024
74ac522
resolving merge conflicts
AlitzelMendez Nov 12, 2024
167c8b6
rule condition should match ARM scenarios
AlitzelMendez Nov 15, 2024
2e0994c
Merge branch 'main' into no-response-body-rule
AlitzelMendez Nov 15, 2024
5f66a18
feedback
AlitzelMendez Nov 15, 2024
bab649a
Merge branch 'no-response-body-rule' of https://github.com/AlitzelMen…
AlitzelMendez Nov 15, 2024
b8c2d3a
Merge branch 'main' into no-response-body-rule
AlitzelMendez Nov 18, 2024
7cb3d71
Merge branch 'main' into no-response-body-rule
AlitzelMendez Nov 25, 2024
2a02191
Add tests
AlitzelMendez Nov 25, 2024
423aa9f
Update packages/typespec-azure-resource-manager/src/rules/no-response…
AlitzelMendez Nov 26, 2024
0d66e23
Update packages/typespec-azure-resource-manager/src/rules/no-response…
AlitzelMendez Nov 26, 2024
17de8e7
Tess feedback
AlitzelMendez Nov 26, 2024
699e115
Merge branch 'main' into no-response-body-rule
markcowl Nov 26, 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
Prev Previous commit
Next Next commit
include only azure subnamespace rule
AlitzelMendez committed Oct 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ebdb33c346851dee218d4166bf2b50287e4db753
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRule, Operation } from "@typespec/compiler";
import { getResponsesForOperation, HttpOperationResponse } from "@typespec/http";

import { isTemplatedInterfaceOperation } from "./utils.js";
import { isAzureSubNamespace, isTemplatedInterfaceOperation } from "./utils.js";

/**
* verify an operation returns 202 or 204 should not contain response body.
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
@@ -22,6 +22,7 @@ export const noResponseBodyRule = createRule({
return {
operation: (op: Operation) => {
if (isTemplatedInterfaceOperation(op)) return;
if (!isAzureSubNamespace(context.program, op.namespace)) return;

const responses = getResponsesForOperation(context.program, op)[0].find(
(v) => v.statusCodes !== 204 && v.statusCodes !== 202,
6 changes: 6 additions & 0 deletions packages/typespec-azure-resource-manager/src/rules/utils.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,12 @@ export function isTemplatedInterfaceOperation(target: Operation) {
);
}

export function isAzureSubNamespace(program: Program, ns: Namespace | undefined): boolean {
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
if (!ns) return false;
const nsName = getNamespaceName(program, ns);
return nsName.startsWith("Azure.");
}

export function isTrackedResource(resourceType: Model) {
const resultKind = getArmResourceKind(resourceType);
return resultKind === "Tracked";