Skip to content

Commit 0f0e4c8

Browse files
committed
docs: document oauth flows fields
1 parent 79281b9 commit 0f0e4c8

File tree

5 files changed

+74
-2
lines changed

5 files changed

+74
-2
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"btreemap",
44
"deque",
55
"deserializable",
6+
"docsrs",
67
"dotenv",
78
"indoc",
89
"ints",

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ rust_2018_idioms = "deny"
1313
nonstandard_style = "deny"
1414
future_incompatible = "deny"
1515
missing_debug_implementations = { level = "warn", priority = -1 }
16+
missing_docs = { level = "warn", priority = -1 }
1617

1718
[workspace.dependencies]
1819
assert_matches = "1"

crates/oas3/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Expose the `spec::ClientCredentialsFlow::token_url` field.
6+
57
## 0.12.1
68

79
- No significant changes since `0.12.0`.

crates/oas3/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
//!
1515
//! [OpenAPI v3.1]: https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md
1616
17+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
18+
1719
use std::{fs::File, io::Read, path::Path};
1820

1921
mod error;

crates/oas3/src/spec/flows.rs

+68-2
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,37 @@ use std::collections::BTreeMap;
33
use serde::{Deserialize, Serialize};
44
use url::Url;
55

6+
use super::spec_extensions;
7+
68
/// Allows configuration of the supported OAuth Flows.
79
///
810
/// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#oauth-flows-object>.
911
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
1012
#[serde(rename_all = "camelCase")]
1113
pub struct Flows {
14+
/// Configuration for the OAuth Implicit flow.
1215
#[serde(skip_serializing_if = "Option::is_none")]
1316
pub implicit: Option<ImplicitFlow>,
1417

18+
/// Configuration for the OAuth Resource Owner Password flow.
1519
#[serde(skip_serializing_if = "Option::is_none")]
1620
pub password: Option<PasswordFlow>,
1721

22+
/// Configuration for the OAuth Client Credentials flow.
1823
#[serde(skip_serializing_if = "Option::is_none")]
1924
pub client_credentials: Option<ClientCredentialsFlow>,
2025

26+
/// Configuration for the OAuth Authorization Code flow.
2127
#[serde(skip_serializing_if = "Option::is_none")]
2228
pub authorization_code: Option<AuthorizationCodeFlow>,
29+
30+
/// Specification extensions.
31+
///
32+
/// Only "x-" prefixed keys are collected, and the prefix is stripped.
33+
///
34+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#specification-extensions>.
35+
#[serde(flatten, with = "spec_extensions")]
36+
pub extensions: BTreeMap<String, serde_json::Value>,
2337
}
2438

2539
/// Configuration details for a implicit OAuth Flow.
@@ -28,12 +42,30 @@ pub struct Flows {
2842
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
2943
#[serde(rename_all = "camelCase")]
3044
pub struct ImplicitFlow {
45+
/// The authorization URL to be used for this flow.
46+
///
47+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
3148
pub authorization_url: Url,
3249

50+
/// The URL to be used for obtaining refresh tokens.
51+
///
52+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
3353
#[serde(skip_serializing_if = "Option::is_none")]
3454
pub refresh_url: Option<Url>,
3555

56+
/// The available scopes for the OAuth2 security scheme.
57+
///
58+
/// A map between the scope name and a short description for it. The map MAY be empty.
59+
#[serde(default)]
3660
pub scopes: BTreeMap<String, String>,
61+
62+
/// Specification extensions.
63+
///
64+
/// Only "x-" prefixed keys are collected, and the prefix is stripped.
65+
///
66+
/// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#specification-extensions>.
67+
#[serde(flatten, with = "spec_extensions")]
68+
pub extensions: BTreeMap<String, serde_json::Value>,
3769
}
3870

3971
/// Configuration details for a password OAuth Flow.
@@ -42,11 +74,21 @@ pub struct ImplicitFlow {
4274
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
4375
#[serde(rename_all = "camelCase")]
4476
pub struct PasswordFlow {
45-
token_url: Url,
77+
/// The token URL to be used for this flow.
78+
///
79+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
80+
pub token_url: Url,
4681

82+
/// The URL to be used for obtaining refresh tokens.
83+
///
84+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
4785
#[serde(skip_serializing_if = "Option::is_none")]
4886
pub refresh_url: Option<Url>,
4987

88+
/// The available scopes for the OAuth2 security scheme.
89+
///
90+
/// A map between the scope name and a short description for it. The map MAY be empty.
91+
#[serde(default)]
5092
pub scopes: BTreeMap<String, String>,
5193
}
5294

@@ -56,11 +98,21 @@ pub struct PasswordFlow {
5698
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
5799
#[serde(rename_all = "camelCase")]
58100
pub struct ClientCredentialsFlow {
59-
token_url: Url,
101+
/// The token URL to be used for this flow.
102+
///
103+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
104+
pub token_url: Url,
60105

106+
/// The URL to be used for obtaining refresh tokens.
107+
///
108+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
61109
#[serde(skip_serializing_if = "Option::is_none")]
62110
pub refresh_url: Option<Url>,
63111

112+
/// The available scopes for the OAuth2 security scheme.
113+
///
114+
/// A map between the scope name and a short description for it. The map MAY be empty.
115+
#[serde(default)]
64116
pub scopes: BTreeMap<String, String>,
65117
}
66118

@@ -70,12 +122,26 @@ pub struct ClientCredentialsFlow {
70122
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
71123
#[serde(rename_all = "camelCase")]
72124
pub struct AuthorizationCodeFlow {
125+
/// The authorization URL to be used for this flow.
126+
///
127+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
73128
pub authorization_url: Url,
129+
130+
/// The token URL to be used for this flow.
131+
///
132+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
74133
pub token_url: Url,
75134

135+
/// The URL to be used for obtaining refresh tokens.
136+
///
137+
/// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
76138
#[serde(skip_serializing_if = "Option::is_none")]
77139
pub refresh_url: Option<Url>,
78140

141+
/// The available scopes for the OAuth2 security scheme.
142+
///
143+
/// A map between the scope name and a short description for it. The map MAY be empty.
144+
#[serde(default)]
79145
pub scopes: BTreeMap<String, String>,
80146
}
81147

0 commit comments

Comments
 (0)