Skip to content

Commit 85b6e63

Browse files
committed
docs: update OAS of reset password routes
1 parent 07e3960 commit 85b6e63

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

www/apps/api-reference/components/Tags/Operation/DescriptionSection/Security/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useBaseSpecs } from "@/providers/base-specs"
22
import type { OpenAPIV3 } from "openapi-types"
33
import { Card } from "docs-ui"
4+
import { useMemo } from "react"
45

56
export type TagsOperationDescriptionSectionSecurityProps = {
67
security: OpenAPIV3.SecurityRequirementObject[]
@@ -11,6 +12,15 @@ const TagsOperationDescriptionSectionSecurity = ({
1112
}: TagsOperationDescriptionSectionSecurityProps) => {
1213
const { getSecuritySchema } = useBaseSpecs()
1314

15+
const linkToAuth = useMemo(() => {
16+
const hasNoAuth = security.some((item) => {
17+
const schema = getSecuritySchema(Object.keys(item)[0])
18+
return schema && schema["x-is-auth"] === false
19+
})
20+
21+
return !hasNoAuth
22+
}, [security, getSecuritySchema])
23+
1424
const getDescription = () => {
1525
let str = ""
1626
security.forEach((item) => {
@@ -27,7 +37,7 @@ const TagsOperationDescriptionSectionSecurity = ({
2737
<Card
2838
title="Authorization"
2939
text={getDescription()}
30-
href="#authentication"
40+
href={linkToAuth ? "#authentication" : undefined}
3141
/>
3242
</div>
3343
)

www/apps/api-reference/types/openapi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export type PropertiesObject = {
105105

106106
export type SecuritySchemeObject = OpenAPIV3.SecuritySchemeObject & {
107107
"x-displayName"?: string
108+
"x-is-auth"?: boolean
108109
}
109110

110111
export type Parameter = OpenAPIV3.ParameterObject & {

www/utils/generated/oas-output/base/admin.oas.base.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,3 +749,8 @@ components:
749749
in: cookie
750750
name: connect.sid
751751
x-displayName: Cookie Session ID
752+
reset_password:
753+
type: http
754+
x-displayName: Reset Password Token
755+
scheme: bearer
756+
x-is-auth: false

www/utils/generated/oas-output/base/store.oas.base.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,8 @@ components:
349349
x-displayName: Cookie Session ID
350350
in: cookie
351351
name: connect.sid
352+
reset_password:
353+
type: http
354+
x-displayName: Reset Password Token
355+
scheme: bearer
356+
x-is-auth: false

www/utils/generated/oas-output/operations/admin/post_auth_[actor_type]_[auth_provider]_update.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* operationId: PostActor_typeAuth_providerUpdate
44
* summary: Reset an Admin User's Password
55
* x-sidebar-summary: Reset Password
6-
* description: Reset an admin user's password using a reset-password token generated with the [Generate Reset Password Token API route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providerresetpassword).
6+
* description: Reset an admin user's password using a reset-password token generated with the [Generate Reset Password Token API route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providerresetpassword). You pass the token as a bearer token in the request's Authorization header.
77
* externalDocs:
88
* url: https://docs.medusajs.com/v2/resources/commerce-modules/auth/authentication-route#reset-password-route
99
* description: Learn more about this API route.
10-
* x-authenticated: false
10+
* x-authenticated: true
1111
* parameters:
1212
* - name: auth_provider
1313
* in: path
@@ -16,12 +16,6 @@
1616
* schema:
1717
* type: string
1818
* example: "emailpass"
19-
* - name: token
20-
* in: query
21-
* description: The reset password token received using the Get Reset Password API route.
22-
* required: true
23-
* schema:
24-
* type: string
2519
* requestBody:
2620
* content:
2721
* application/json:
@@ -36,12 +30,15 @@
3630
* - lang: Shell
3731
* label: cURL
3832
* source: |-
39-
* curl -X POST '{backend_url}/auth/user/emailpass/update?token=123' \
33+
* curl -X POST '{backend_url}/auth/user/emailpass/update' \
4034
* -H 'Content-Type: application/json' \
35+
* -H 'Authorization: Bearer {token}' \
4136
* --data-raw '{
4237
* "email": "admin@medusa-test.com",
4338
* "password": "supersecret"
4439
* }'
40+
* security:
41+
* - reset_password: []
4542
* tags:
4643
* - Auth
4744
* responses:

www/utils/generated/oas-output/operations/store/post_auth_[actor_type]_[auth_provider]_update.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* operationId: PostActor_typeAuth_providerUpdate
44
* summary: Reset a Customer's Password
55
* x-sidebar-summary: Reset Password
6-
* description: Reset a customer's password using a reset-password token generated with the [Generate Reset Password Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_providerresetpassword).
6+
* description: Reset a customer's password using a reset-password token generated with the [Generate Reset Password Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_providerresetpassword). You pass the token as a bearer token in the request's Authorization header.
77
* externalDocs:
88
* url: https://docs.medusajs.com/v2/resources/storefront-development/customers/reset-password#2-reset-password-page
99
* description: "Storefront development: How to create the reset password page."
10-
* x-authenticated: false
10+
* x-authenticated: true
1111
* parameters:
1212
* - name: auth_provider
1313
* in: path
@@ -16,12 +16,6 @@
1616
* schema:
1717
* type: string
1818
* example: "emailpass"
19-
* - name: token
20-
* in: query
21-
* description: The reset password token received using the Get Reset Password API route.
22-
* required: true
23-
* schema:
24-
* type: string
2519
* requestBody:
2620
* content:
2721
* application/json:
@@ -36,12 +30,15 @@
3630
* - lang: Shell
3731
* label: cURL
3832
* source: |-
39-
* curl -X POST '{backend_url}/auth/customer/emailpass/update?token=123' \
33+
* curl -X POST '{backend_url}/auth/customer/emailpass/update' \
4034
* -H 'Content-Type: application/json' \
35+
* -H 'Authorization: Bearer {token}' \
4136
* --data-raw '{
4237
* "email": "customer@gmail.com",
4338
* "password": "supersecret"
4439
* }'
40+
* security:
41+
* - reset_password: []
4542
* tags:
4643
* - Auth
4744
* responses:

0 commit comments

Comments
 (0)