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

[Bug]: Invisible decorator doesn't work #5450

Closed
4 tasks done
wanlwanl opened this issue Dec 26, 2024 · 2 comments · Fixed by #5525
Closed
4 tasks done

[Bug]: Invisible decorator doesn't work #5450

wanlwanl opened this issue Dec 26, 2024 · 2 comments · Fixed by #5525
Assignees
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core

Comments

@wanlwanl
Copy link
Member

Describe the bug

In line 41, invisible decorator doesn't wotk, it still generate validated.

@jsonSchema
model User {
...
  @invisible(Lifecycle) validated: boolean;
}

Reproduction

Reproduce in this way, check line 41
Playground

Checklist

@witemple-msft
Copy link
Member

This is caused by the openapi3 emitter and projectProgram. Since the visibility system uses strong type references as keys, I'll need to add some logic that handles projections specially.

@witemple-msft
Copy link
Member

@wanlwanl Thanks for the report! This was related to another issue observed with the enum-driven visibility system interacting with projections, which are used in our OpenAPIv3 emitter. The linked PR fixes the issue and adds some tests against regressions.

github-merge-queue bot pushed a commit that referenced this issue Jan 8, 2025
… are used (#5525)

- Changed `getLifecycleVisibilityEnum` to honor projections when
`program` is a `ProjectedProgram`.
- Taught `Projector` to project `EnumValue` values only, so that they
remain consistent with projected `Enum` and `EnumMember` references. If
the projection of the underlying `EnumMember` does not result in another
`EnumMember` (i.e. it projects to some other type, which I think should
be rare, but possible according to the type system), the projector gives
up and returns the original enum member.

A more complex solution would try to project all values, but this could
damage the scalar hierarchy and there is an open issue to consider
removing projections in favor of mutators in the future.

Closes #5450
Closes #5461

---------

Co-authored-by: Will Temple <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core
Projects
None yet
3 participants