chore(oas): Fix OAS related to JWT authentication (#5448)

* chore(oas): Fix OAS related to JWT authentication

* generate openapi spec files

* remove L option in curl examples
This commit is contained in:
Shahed Nasser
2023-10-23 11:48:02 +03:00
committed by GitHub
parent 1a10822cae
commit c67d490db3
34 changed files with 65 additions and 93 deletions

View File

@@ -4,6 +4,6 @@ medusa.admin.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ accessToken }) => {
console.log(accessToekn);
.then(({ access_token }) => {
console.log(access_token);
});

View File

@@ -1,5 +1,5 @@
curl --location --request POST 'https://medusa-url.com/admin/auth/token' \
--header 'Content-Type: application/json' \
curl -X POST '{backend_url}/admin/auth/token' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"

View File

@@ -1,5 +1,5 @@
type: object
properties:
accessToken:
description: Access token for subsequent authorization.
access_token:
description: Access token that can be used to send authenticated requests.
type: string

View File

@@ -3,24 +3,13 @@ post:
summary: User Login (JWT)
x-authenticated: false
description: >-
After a successful login, a JWT token is returned for subsequent
authorization.
parameters: []
After a successful login, a JWT token is returned, which can be used to send
authenticated requests.
requestBody:
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email:
type: string
description: The User's email.
password:
type: string
description: The User's password.
$ref: ../components/schemas/AdminPostAuthReq.yaml
x-codegen:
method: getToken
x-codeSamples:

View File

@@ -1,9 +1,9 @@
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.store.auth.getToken({
medusa.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ accessToken }) => {
console.log(accessToken);
.then(({ access_token }) => {
console.log(access_token);
});

View File

@@ -1,2 +1,2 @@
curl -X DELETE '{backend_url}/store/auth' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -1,2 +1,2 @@
curl '{backend_url}/store/auth' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -0,0 +1,6 @@
curl -X POST '{backend_url}/store/auth/token' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'

View File

@@ -1,2 +1,2 @@
curl '{backend_url}/store/customers/me' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -1,5 +1,5 @@
curl -X POST '{backend_url}/store/customers/me' \
-H 'Cookie: connect.sid={sid}' \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Laury"

View File

@@ -1,5 +1,5 @@
curl -X POST '{backend_url}/store/customers/me/addresses' \
-H 'Cookie: connect.sid={sid}' \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
"address": {

View File

@@ -1,2 +1,2 @@
curl -X DELETE '{backend_url}/store/customers/me/addresses/{address_id}' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -1,5 +1,5 @@
curl -X POST '{backend_url}/store/customers/me/addresses/{address_id}' \
-H 'Cookie: connect.sid={sid}' \
-H 'Authorization: Bearer {access_token}' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "Gina"

View File

@@ -1,2 +1,2 @@
curl '{backend_url}/store/customers/me/orders' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -1,2 +1,2 @@
curl '{backend_url}/store/customers/me/payment-methods' \
-H 'Cookie: connect.sid={sid}'
-H 'Authorization: Bearer {access_token}'

View File

@@ -1,6 +0,0 @@
curl --location --request POST 'https://medusa-url.com/store/auth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "supersecret"
}'

View File

@@ -1,5 +1,5 @@
type: object
properties:
accessToken:
description: Access token for subsequent authorization.
access_token:
description: Access token that can be used to send authenticated requests.
type: string

View File

@@ -154,6 +154,8 @@ servers:
paths:
/store/auth:
$ref: paths/store_auth.yaml
/store/auth/token:
$ref: paths/store_auth_token.yaml
/store/auth/{email}:
$ref: paths/store_auth_{email}.yaml
/store/carts:
@@ -262,8 +264,6 @@ paths:
$ref: paths/store_swaps.yaml
/store/swaps/{cart_id}:
$ref: paths/store_swaps_{cart_id}.yaml
/store/token:
$ref: paths/store_token.yaml
/store/variants:
$ref: paths/store_variants.yaml
/store/variants/{id}:

View File

@@ -3,35 +3,24 @@ post:
summary: Customer Login (JWT)
x-authenticated: false
description: >-
After a successful login, a JWT token is returned for subsequent
authorization.
parameters: []
After a successful login, a JWT token is returned, which can be used to send
authenticated requests.
requestBody:
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email:
type: string
description: The User's email.
password:
type: string
description: The User's password.
$ref: ../components/schemas/StorePostAuthReq.yaml
x-codegen:
method: getToken
x-codeSamples:
- lang: JavaScript
label: JS Client
source:
$ref: ../code_samples/JavaScript/store_token/post.js
$ref: ../code_samples/JavaScript/store_auth_token/post.js
- lang: Shell
label: cURL
source:
$ref: ../code_samples/Shell/store_token/post.sh
$ref: ../code_samples/Shell/store_auth_token/post.sh
tags:
- Auth
responses: