Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions awesomeness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
# This feels like sliding down a warm fudge mountain; I dearly hope the github action
# we write if this works can maintain this simplicity
find codegen/specs/stytch -name "*.yml" -delete
find codegen/specs/stytch_b2b -name "*.yml" -delete

find ../protobuf/api -name "*.yml.python" |
while read line
do

consumerFile=`echo $line | sed 's|.*/\([^.]*\).yml.python$|codegen/specs/stytch/\1.yml|'`
b2bFile=`echo $line | sed 's|.*/\([^.]*\).yml.python$|codegen/specs/stytch_b2b/\1.yml|'`

# filter for the appropriate methods then put them in the appropriate spec folder
cat $line | yq -y '.methods=[.methods[] |
select(.vertical == "CONSUMER") |
select(.include_in_backend_sdk_codegen == true) |
del(.vertical) |
del(.include_in_backend_sdk_codegen)]' |
sed 's/methods: \[\]/methods: /' > $consumerFile

cat $line | yq -y '.methods=[.methods[] |
select(.vertical == "B2B") |
select(.include_in_backend_sdk_codegen == true) |
del(.vertical) |
del(.include_in_backend_sdk_codegen)]' |
sed 's/methods: \[\]/methods: /' > $b2bFile

# then we have to tack the ALL vertical methods onto both files
cat $line | yq -y '[.methods[] |
select(.vertical == "ALL") |
select(.include_in_backend_sdk_codegen == true) |
del(.vertical) |
del(.include_in_backend_sdk_codegen)]' |
sed 's/^/ /' |
grep -v "^ *\[\] *$" >> $consumerFile

cat $line | yq -y '[.methods[] |
select(.vertical == "ALL") |
select(.include_in_backend_sdk_codegen == true) |
del(.vertical) |
del(.include_in_backend_sdk_codegen)]' |
sed 's/^/ /' |
grep -v "^ *\[\] *$" >> $b2bFile


done

# delete any files that are only 2 lines because they're just a classname and
# a null methods entry
find . -name "*.yml" | xargs wc -l | awk '/^ *2 / {print $2}' | xargs rm

./bin/generate-api.sh
7 changes: 4 additions & 3 deletions bin/generate-api.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
SCRIPT_DIR=`echo "$0" | sed 's|[^/]*$||'`

cd "$SCRIPT_DIR/.." || exit 1
python -m codegen.generate codegen/specs/stytch/ stytch/api stytch/models --docs_dir=codegen/specs/stytch/docs
python -m codegen.generate codegen/specs/stytch_b2b/ stytch/b2b/api stytch/b2b/models --docs_dir=codegen/specs/stytch_b2b/docs

python3 -m codegen.generate codegen/specs/stytch/ stytch/api stytch/models --docs_dir=codegen/specs/stytch/docs
python3 -m codegen.generate codegen/specs/stytch_b2b/ stytch/b2b/api stytch/b2b/models --docs_dir=codegen/specs/stytch_b2b/docs
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
classname: CryptoWallets
classname: CryptoWalletService
methods:
- name: authenticate_start
api_path: authenticate/start
method: POST
- name: CryptoWalletsAuthenticateStart
args:
- name: crypto_wallet_address
arg_type: str
- name: crypto_wallet_type
arg_type: str
- name: crypto_wallet_address
arg_type: str
- name: user_id
arg_type: Optional[str] = None
- name: session_token
arg_type: Optional[str] = None
- name: session_jwt
arg_type: Optional[str] = None
response_type:
request_id: str
user_id: str
challenge: str
user_created: bool
- name: authenticate
method: POST
method: post
api_path: /v1/crypto_wallets/authenticate/start
- name: CryptoWalletsAuthenticate
args:
- name: crypto_wallet_address
arg_type: str
- name: crypto_wallet_type
arg_type: str
- name: crypto_wallet_address
arg_type: str
- name: signature
arg_type: str
- name: session_token
arg_type: Optional[str] = None
- name: session_jwt
arg_type: Optional[str] = None
- name: session_duration_minutes
arg_type: Optional[int] = None
- name: session_jwt
arg_type: Optional[str] = None
- name: session_custom_claims
arg_type: Optional[Dict[str, Any]] = None
response_type:
request_id: str
user_id: str
user: User
session_jwt: str
session_token: str
session: Optional[StytchSession]
session_jwt: str
user: User
method: post
api_path: /v1/crypto_wallets/authenticate
10 changes: 10 additions & 0 deletions codegen/specs/stytch/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
classname: DebugService
methods:
- name: WhoAmI
args: []
response_type:
request_id: str
project_id: str
name: str
method: get
api_path: /v1/debug/whoami
Loading