Skip to content

Commit

Permalink
Fix scopes in README
Browse files Browse the repository at this point in the history
  • Loading branch information
hv-leo committed Aug 5, 2024
1 parent 467e559 commit 30f61e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ await fastify.register(import('@fastify/fastify-openapi-router-plugin'), {
operationId: 'getPetById',
...
security: [
{ OAuth2: ['read:pets'] }
{ OAuth2: ['pets:read'] }
]
}
}
Expand Down Expand Up @@ -136,7 +136,7 @@ await fastify.register(import('@fastify/fastify-openapi-router-plugin'), {
```

> [!TIP]
> The `scopes` returned by the security handler can contain **wildcards**. For example, if the security handler returns `{ scopes: ['read:*'] }`, the route will be authorized for any security scope that starts with `read:`.
> The `scopes` returned by the security handler can contain **wildcards**. For example, if the security handler returns `{ scopes: ['pets:*'] }`, the route will be authorized for any security scope that starts with `pets:`.
> [!IMPORTANT]
> If your specification uses `http` security schemes with `in: cookie`, you must register [@fastify/cookie](https://github.com/fastify/fastify-cookie) before this plugin.
Expand Down
2 changes: 1 addition & 1 deletion examples/petstore/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ await fastify.register(openApiRouter, {
data: {
user: { name: 'John Doe' }
},
scopes: ['read:pets']
scopes: ['pets:read']
};
}
},
Expand Down
20 changes: 10 additions & 10 deletions examples/petstore/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
],
"requestBody": {
Expand All @@ -85,7 +85,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
],
"requestBody": {
Expand Down Expand Up @@ -144,7 +144,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
]
}
Expand Down Expand Up @@ -198,7 +198,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
],
"deprecated": true
Expand Down Expand Up @@ -250,7 +250,7 @@
},
"security": [
{
"petstore_auth": ["write:pets"],
"petstore_auth": ["pets:write"],
"api_key": []
},
{
Expand Down Expand Up @@ -283,7 +283,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
],
"requestBody": {
Expand Down Expand Up @@ -341,7 +341,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
]
}
Expand Down Expand Up @@ -378,7 +378,7 @@
},
"security": [
{
"petstore_auth": ["write:pets", "read:pets"]
"petstore_auth": ["pets:write", "pets:read"]
}
],
"requestBody": {
Expand Down Expand Up @@ -977,8 +977,8 @@
"implicit": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
"pets:write": "modify pets in your account",
"pets:read": "read your pets"
}
}
}
Expand Down

0 comments on commit 30f61e1

Please sign in to comment.