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

Unable to override HTTP method from operation template - issue #3636 #3637

Closed
wants to merge 3 commits into from

Conversation

johanste
Copy link
Contributor

@johanste johanste commented Jun 20, 2024

  • Makes overriding of existing HTTP method into a warning rather than an error

Fixes #3636

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jun 20, 2024

All changed packages have been documented.

  • @typespec/http
Show changes

@typespec/http - fix ✏️

Unable to override HTTP method from operation template - issue #3636

@azure-sdk
Copy link
Collaborator

You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/3637/

Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/prs/3637/

@@ -4,7 +4,7 @@ export const $lib = createTypeSpecLibrary({
name: "@typespec/http",
diagnostics: {
"http-verb-duplicate": {
severity: "error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t feel like I agree with making this a warning, we have the same pattern for other decorators. It doesn’t make sense to specify 2 verb on the exact same node. We should just allow it to override but complain if it’s specified on the same node not operation. Having to suppress that warning when you want to pverrride with op is just feels wrong anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to remove the warning altogether, I would not be opposed to it.

I don't think I'd bother with checking/warn if you specified it twice on the same node, though - I think you get exactly what you asked for.

Copy link
Member

@timotheeguerin timotheeguerin Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i think the following should be an error

@get @get op op1(): void;
@get @post op op2(): void;

but this should not emit any errors/warning

@get op base(): void;

@post op override is base;

Playground

Copy link
Member

@timotheeguerin timotheeguerin Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hhm I guess duplicate-decorator which is the common diagnostic we emit for duplicate use is a warning not error so that can stay a warning, still it shouldn't need to be suppress and only emit this diagnositc when annotating the same node twice(existing logic is validateDecoratorUniqueOnNode)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is getting warnings for multiple decorator instances on the same node here a blocker? I can add another utility function to handle the case where there can only be one instance in a "family" of decorators on a given node, but it feels like a low priority thing. If I wasn't digging around in this code to begin with, I would have said it goes on the backlog... and I'm tempted to say so even if I'm digging around in this code.

Copy link
Member

@timotheeguerin timotheeguerin Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well from experience seeing how a significant amount of azure spec written don’t see those as warning but errors(warn as error) I do think it is quite a bad experience that will lead to more question we have to keep answering

@timotheeguerin
Copy link
Member

New PR fixing this as design meeting said #3717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to override HTTP method from operation template
4 participants