Skip to content

Conversation

@timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Aug 11, 2022

Change the scopes from string[] to {value: string, description?: string}. There is no way yet to set the description in Cadl but this unblock issue with the Arm generated swagger specs.

https://github.com/Azure/cadl-azure/pull/1855

I think to allow description in the cadl document for scopes the flow should allow taking an enum instead of tuple of string(either one) that way you can have things like

enum MyOAuth2Scopes {
   @doc("Permission to read")
   read: "https://myservice.com/read",

   @doc("Permission to write")
   write: "https://myservice.com/write",
}

@azure-pipelines
Copy link

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

@timotheeguerin timotheeguerin enabled auto-merge (squash) August 17, 2022 21:58
@timotheeguerin timotheeguerin merged commit 1ef6e5f into microsoft:main Aug 17, 2022
@timotheeguerin timotheeguerin deleted the update-for-swagger-linter branch June 9, 2023 20:01
steverice added a commit to pinterest/typespec that referenced this pull request Jan 29, 2025
This makes a small change to the code introduced in microsoft#849 to allow for models to be used as OAuth scopes.
Without this check, an object like `{value: "foo", description: "bar"}` gets wrapped in an additional `value` key.
When the OpenAPI3 emitter tries to print out the `securitySchemes`, it sees `{value: {...}}` and produces a scope with value `[object Object]` and no description.

Here instead we check for an object and prevent the wrapping.
steverice added a commit to pinterest/typespec that referenced this pull request Dec 2, 2025
This makes a small change to the code introduced in microsoft#849 to allow for models to be used as OAuth scopes.
Without this check, an object like `{value: "foo", description: "bar"}` gets wrapped in an additional `value` key.
When the OpenAPI3 emitter tries to print out the `securitySchemes`, it sees `{value: {...}}` and produces a scope with value `[object Object]` and no description.

This also introduces a base `SecurityScheme` model that allows for more specific type checking on the `@useAuth` decorator.
steverice added a commit to pinterest/typespec that referenced this pull request Dec 2, 2025
This makes a small change to the code introduced in microsoft#849 to allow for models to be used as OAuth scopes.
Without this check, an object like `{value: "foo", description: "bar"}` gets wrapped in an additional `value` key.
When the OpenAPI3 emitter tries to print out the `securitySchemes`, it sees `{value: {...}}` and produces a scope with value `[object Object]` and no description.

This also introduces a base `SecurityScheme` model that allows for more specific type checking on the `@useAuth` decorator.

We need to remove an `openapi3` test that checks for an error when providing an unsupported auth type.
Now the compiler enforces that the auth type is `AuthType`, and `openapi3` supports all of the types in `AuthType`, it should not be possible to trigger this condition in TSP.
steverice added a commit to pinterest/typespec that referenced this pull request Dec 3, 2025
This makes a small change to the code introduced in microsoft#849 to allow for models to be used as OAuth scopes.
Without this check, an object like `{value: "foo", description: "bar"}` gets wrapped in an additional `value` key.
When the OpenAPI3 emitter tries to print out the `securitySchemes`, it sees `{value: {...}}` and produces a scope with value `[object Object]` and no description.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants