Skip to content

Commit ffaa39f

Browse files
authored
add codegen HTTP client (#1)
* check in generated dir * rustfmt codegen * add codemod * apply to codegen * combine codemod with generate script
1 parent ba3b9d0 commit ffaa39f

File tree

107 files changed

+3561
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3561
-0
lines changed

generate.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]; then
4+
echo "Required generator file is missing."
5+
exit 1
6+
fi
7+
8+
file="$1"
9+
10+
# Function to remove lines between start and end markers
11+
remove_lines_between_markers() {
12+
local file=$1
13+
local start_marker=$2
14+
local end_marker=$3
15+
16+
# Use sed to remove lines between start and end markers, inclusive
17+
sed -i '' -e "/$start_marker/,/$end_marker/d" "$file"
18+
}
19+
20+
# Function to process a single Rust file
21+
process_rust_file() {
22+
local file=$1
23+
24+
# Temporary file to store line numbers for start and end markers
25+
tmp_file=$(mktemp)
26+
27+
# Find lines that start with 'impl ' and don't contain 'fmt::Display'
28+
grep -n '^impl ' "$file" | grep -vE 'Configuration|fmt::Display|fmt::Debug|From<' > "$tmp_file"
29+
30+
# Read line numbers and process each block in reverse order
31+
tac "$tmp_file" | while IFS= read -r line; do
32+
# Extract line number from grep output
33+
start_line=$(echo "$line" | cut -d: -f1)
34+
35+
# Find the end line (next line with only a '}')
36+
end_line=$(awk "NR>$start_line && /^}$/ {print NR; exit}" "$file")
37+
38+
if [[ -n "$end_line" ]]; then
39+
# Build the marker strings
40+
start_marker="^$(sed "${start_line}q;d" "$file")$"
41+
end_marker="^$(sed "${end_line}q;d" "$file")$"
42+
43+
# Remove lines between markers
44+
remove_lines_between_markers "$file" "$start_marker" "$end_marker"
45+
fi
46+
done
47+
48+
# Clean up temporary file
49+
rm "$tmp_file"
50+
51+
# Remove 'Default' from #[derive(...)] lines
52+
sed -i '' -E 's/(\#\[derive\([^\)]*)Default,?\s*/\1/' "$file"
53+
}
54+
55+
# Function to recursively process all Rust files in a directory
56+
process_directory() {
57+
local dir=$1
58+
59+
# Find all Rust files and process them
60+
find "$dir" -type f -name "*.rs" | while IFS= read -r rust_file; do
61+
echo "Processing $rust_file..."
62+
process_rust_file "$rust_file"
63+
done
64+
}
65+
66+
# Remove codegen output from previous run
67+
rm -rf ./openapi
68+
69+
# Run codegen
70+
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
71+
-i "/local/$file" \
72+
-g rust \
73+
-o /local/openapi \
74+
--additional-properties=packageVersion=0.1.0
75+
76+
# Apply codemod to codegen
77+
process_directory "openapi"

openapi/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target/
2+
**/*.rs.bk
3+
Cargo.lock

openapi/.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

openapi/.openapi-generator/FILES

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
.gitignore
2+
.openapi-generator-ignore
3+
.travis.yml
4+
Cargo.toml
5+
README.md
6+
docs/AppInfo.md
7+
docs/AppResponse.md
8+
docs/AppleUserSocialConnection.md
9+
docs/AppsApi.md
10+
docs/AuthMethods.md
11+
docs/AuthenticateApi.md
12+
docs/AuthenticateVerifyNonceResponse.md
13+
docs/CreateTransactionAuthenticateRequest.md
14+
docs/CreateTransactionRegisterRequest.md
15+
docs/CreateTransactionResponse.md
16+
docs/ElementCustomization.md
17+
docs/FontFamily.md
18+
docs/GithubUserSocialConnection.md
19+
docs/GoogleUserSocialConnection.md
20+
docs/LayoutConfig.md
21+
docs/Layouts.md
22+
docs/Link.md
23+
docs/ListDevicesResponse.md
24+
docs/ListPaginatedUsersItem.md
25+
docs/ListPaginatedUsersResponse.md
26+
docs/MagicLinkAuthMethod.md
27+
docs/Model400Error.md
28+
docs/Model401Error.md
29+
docs/Model403Error.md
30+
docs/Model404Error.md
31+
docs/Model409Error.md
32+
docs/Model500Error.md
33+
docs/Nonce.md
34+
docs/OtpAuthMethod.md
35+
docs/PaginatedLinks.md
36+
docs/PasskeysAuthMethod.md
37+
docs/Technologies.md
38+
docs/TransactionsApi.md
39+
docs/TtlDisplayUnit.md
40+
docs/UserDevicesApi.md
41+
docs/UserEventStatus.md
42+
docs/UserInfo.md
43+
docs/UserMetadataField.md
44+
docs/UserMetadataFieldType.md
45+
docs/UserRecentEvent.md
46+
docs/UserResponse.md
47+
docs/UserSocialConnections.md
48+
docs/UserStatus.md
49+
docs/UsersApi.md
50+
docs/WebAuthnDevices.md
51+
docs/WebAuthnIcons.md
52+
docs/WebAuthnType.md
53+
git_push.sh
54+
src/apis/apps_api.rs
55+
src/apis/authenticate_api.rs
56+
src/apis/configuration.rs
57+
src/apis/mod.rs
58+
src/apis/transactions_api.rs
59+
src/apis/user_devices_api.rs
60+
src/apis/users_api.rs
61+
src/lib.rs
62+
src/models/app_info.rs
63+
src/models/app_response.rs
64+
src/models/apple_user_social_connection.rs
65+
src/models/auth_methods.rs
66+
src/models/authenticate_verify_nonce_response.rs
67+
src/models/create_transaction_authenticate_request.rs
68+
src/models/create_transaction_register_request.rs
69+
src/models/create_transaction_response.rs
70+
src/models/element_customization.rs
71+
src/models/font_family.rs
72+
src/models/github_user_social_connection.rs
73+
src/models/google_user_social_connection.rs
74+
src/models/layout_config.rs
75+
src/models/layouts.rs
76+
src/models/link.rs
77+
src/models/list_devices_response.rs
78+
src/models/list_paginated_users_item.rs
79+
src/models/list_paginated_users_response.rs
80+
src/models/magic_link_auth_method.rs
81+
src/models/mod.rs
82+
src/models/model_400_error.rs
83+
src/models/model_401_error.rs
84+
src/models/model_403_error.rs
85+
src/models/model_404_error.rs
86+
src/models/model_409_error.rs
87+
src/models/model_500_error.rs
88+
src/models/nonce.rs
89+
src/models/otp_auth_method.rs
90+
src/models/paginated_links.rs
91+
src/models/passkeys_auth_method.rs
92+
src/models/technologies.rs
93+
src/models/ttl_display_unit.rs
94+
src/models/user_event_status.rs
95+
src/models/user_info.rs
96+
src/models/user_metadata_field.rs
97+
src/models/user_metadata_field_type.rs
98+
src/models/user_recent_event.rs
99+
src/models/user_response.rs
100+
src/models/user_social_connections.rs
101+
src/models/user_status.rs
102+
src/models/web_authn_devices.rs
103+
src/models/web_authn_icons.rs
104+
src/models/web_authn_type.rs

openapi/.openapi-generator/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.8.0-SNAPSHOT

openapi/.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: rust

openapi/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "openapi"
3+
version = "0.1.0"
4+
authors = ["support@passage.id"]
5+
description = "Passage's management API to manage your Passage apps and users."
6+
# Override this license by providing a License Object in the OpenAPI.
7+
license = "Unlicense"
8+
edition = "2021"
9+
10+
[dependencies]
11+
serde = { version = "^1.0", features = ["derive"] }
12+
serde_json = "^1.0"
13+
serde_repr = "^0.1"
14+
url = "^2.5"
15+
uuid = { version = "^1.8", features = ["serde", "v4"] }
16+
reqwest = { version = "^0.12", features = ["json", "multipart"] }

openapi/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Rust API client for openapi
2+
3+
Passage's management API to manage your Passage apps and users.
4+
5+
For more information, please visit [https://passage.id/support](https://passage.id/support)
6+
7+
## Overview
8+
9+
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
10+
11+
- API version: 1
12+
- Package version: 0.1.0
13+
- Generator version: 7.8.0-SNAPSHOT
14+
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
15+
16+
## Installation
17+
18+
Put the package under your project folder in a directory named `openapi` and add the following to `Cargo.toml` under `[dependencies]`:
19+
20+
```
21+
openapi = { path = "./openapi" }
22+
```
23+
24+
## Documentation for API Endpoints
25+
26+
All URIs are relative to *https://api.passage.id/v1/apps/TODO*
27+
28+
Class | Method | HTTP request | Description
29+
------------ | ------------- | ------------- | -------------
30+
*AppsApi* | [**get_app**](docs/AppsApi.md#get_app) | **GET** / | Get App
31+
*AuthenticateApi* | [**authenticate_verify_nonce**](docs/AuthenticateApi.md#authenticate_verify_nonce) | **POST** /authenticate/verify | Verify the nonce received from a WebAuthn ceremony
32+
*TransactionsApi* | [**create_authenticate_transaction**](docs/TransactionsApi.md#create_authenticate_transaction) | **POST** /transactions/authenticate | Create a transaction to start a user's authentication process
33+
*TransactionsApi* | [**create_register_transaction**](docs/TransactionsApi.md#create_register_transaction) | **POST** /transactions/register | Create a transaction to start a user's registration process
34+
*UserDevicesApi* | [**delete_user_devices**](docs/UserDevicesApi.md#delete_user_devices) | **DELETE** /users/{user_id}/devices/{device_id} | Delete a device for a user
35+
*UserDevicesApi* | [**list_user_devices**](docs/UserDevicesApi.md#list_user_devices) | **GET** /users/{user_id}/devices | List User Devices
36+
*UsersApi* | [**get_user**](docs/UsersApi.md#get_user) | **GET** /users/{user_id} | Get User
37+
*UsersApi* | [**list_paginated_users**](docs/UsersApi.md#list_paginated_users) | **GET** /users | List Users
38+
39+
40+
## Documentation For Models
41+
42+
- [AppInfo](docs/AppInfo.md)
43+
- [AppResponse](docs/AppResponse.md)
44+
- [AppleUserSocialConnection](docs/AppleUserSocialConnection.md)
45+
- [AuthMethods](docs/AuthMethods.md)
46+
- [AuthenticateVerifyNonceResponse](docs/AuthenticateVerifyNonceResponse.md)
47+
- [CreateTransactionAuthenticateRequest](docs/CreateTransactionAuthenticateRequest.md)
48+
- [CreateTransactionRegisterRequest](docs/CreateTransactionRegisterRequest.md)
49+
- [CreateTransactionResponse](docs/CreateTransactionResponse.md)
50+
- [ElementCustomization](docs/ElementCustomization.md)
51+
- [FontFamily](docs/FontFamily.md)
52+
- [GithubUserSocialConnection](docs/GithubUserSocialConnection.md)
53+
- [GoogleUserSocialConnection](docs/GoogleUserSocialConnection.md)
54+
- [LayoutConfig](docs/LayoutConfig.md)
55+
- [Layouts](docs/Layouts.md)
56+
- [Link](docs/Link.md)
57+
- [ListDevicesResponse](docs/ListDevicesResponse.md)
58+
- [ListPaginatedUsersItem](docs/ListPaginatedUsersItem.md)
59+
- [ListPaginatedUsersResponse](docs/ListPaginatedUsersResponse.md)
60+
- [MagicLinkAuthMethod](docs/MagicLinkAuthMethod.md)
61+
- [Model400Error](docs/Model400Error.md)
62+
- [Model401Error](docs/Model401Error.md)
63+
- [Model403Error](docs/Model403Error.md)
64+
- [Model404Error](docs/Model404Error.md)
65+
- [Model409Error](docs/Model409Error.md)
66+
- [Model500Error](docs/Model500Error.md)
67+
- [Nonce](docs/Nonce.md)
68+
- [OtpAuthMethod](docs/OtpAuthMethod.md)
69+
- [PaginatedLinks](docs/PaginatedLinks.md)
70+
- [PasskeysAuthMethod](docs/PasskeysAuthMethod.md)
71+
- [Technologies](docs/Technologies.md)
72+
- [TtlDisplayUnit](docs/TtlDisplayUnit.md)
73+
- [UserEventStatus](docs/UserEventStatus.md)
74+
- [UserInfo](docs/UserInfo.md)
75+
- [UserMetadataField](docs/UserMetadataField.md)
76+
- [UserMetadataFieldType](docs/UserMetadataFieldType.md)
77+
- [UserRecentEvent](docs/UserRecentEvent.md)
78+
- [UserResponse](docs/UserResponse.md)
79+
- [UserSocialConnections](docs/UserSocialConnections.md)
80+
- [UserStatus](docs/UserStatus.md)
81+
- [WebAuthnDevices](docs/WebAuthnDevices.md)
82+
- [WebAuthnIcons](docs/WebAuthnIcons.md)
83+
- [WebAuthnType](docs/WebAuthnType.md)
84+
85+
86+
To get access to the crate's generated documentation, use:
87+
88+
```
89+
cargo doc --open
90+
```
91+
92+
## Author
93+
94+
support@passage.id
95+

openapi/docs/AppInfo.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AppInfo
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**additional_auth_origins** | **Vec<String>** | |
8+
**allowed_callback_urls** | **Vec<String>** | The valid URLs where users can be redirected after authentication. |
9+
**allowed_identifier** | **String** | |
10+
**allowed_logout_urls** | **Vec<String>** | The valid URLs where users can be redirected after logging out. |
11+
**application_login_uri** | **String** | A route within your application that redirects to the Authorization URL endpoint. |
12+
**auth_fallback_method** | **String** | Deprecated Property. Please refer to `auth_methods` to view settings for individual authentication methods. |
13+
**auth_fallback_method_ttl** | **i32** | Deprecated Property. Please refer to `auth_methods` to view settings for individual authentication methods. |
14+
**auth_methods** | [**models::AuthMethods**](AuthMethods.md) | |
15+
**auth_origin** | **String** | |
16+
**auto_theme_enabled** | **bool** | |
17+
**created_at** | **String** | |
18+
**default_language** | **String** | |
19+
**id** | **String** | |
20+
**layouts** | [**models::Layouts**](Layouts.md) | |
21+
**login_url** | **String** | |
22+
**light_logo_url** | Option<**String**> | | [optional]
23+
**dark_logo_url** | Option<**String**> | | [optional]
24+
**name** | **String** | |
25+
**hosted** | **bool** | whether or not the app's login page hosted by passage |
26+
**hosted_subdomain** | **String** | the subdomain of the app's hosted login page |
27+
**id_token_lifetime** | Option<**i32**> | | [optional]
28+
**passage_branding** | **bool** | |
29+
**profile_management** | **bool** | |
30+
**public_signup** | **bool** | |
31+
**redirect_url** | **String** | |
32+
**refresh_absolute_lifetime** | **i32** | |
33+
**refresh_enabled** | **bool** | |
34+
**refresh_inactivity_lifetime** | **i32** | |
35+
**require_email_verification** | **bool** | |
36+
**require_identifier_verification** | **bool** | |
37+
**required_identifier** | **String** | |
38+
**role** | **String** | |
39+
**rsa_public_key** | **String** | |
40+
**secret** | Option<**String**> | can only be retrieved by an app admin | [optional]
41+
**session_timeout_length** | **i32** | |
42+
**r#type** | **String** | |
43+
**user_metadata_schema** | [**Vec<models::UserMetadataField>**](UserMetadataField.md) | |
44+
**technologies** | [**Vec<models::Technologies>**](Technologies.md) | |
45+
**element_customization** | [**models::ElementCustomization**](ElementCustomization.md) | |
46+
**element_customization_dark** | [**models::ElementCustomization**](ElementCustomization.md) | |
47+
48+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
49+
50+

openapi/docs/AppResponse.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# AppResponse
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**app** | [**models::AppInfo**](AppInfo.md) | |
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+

0 commit comments

Comments
 (0)