Skip to content

Commit

Permalink
Add disclaimer support (#83)
Browse files Browse the repository at this point in the history
* Add disclaimer for okta library

* Add suppor for disclaimers

* Bump version
  • Loading branch information
augustuswm authored Sep 1, 2023
1 parent 4ea6e48 commit 31f85e8
Show file tree
Hide file tree
Showing 67 changed files with 154 additions and 94 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := bash

VERSION = 0.7.0
VERSION = 0.7.1

DOCUSIGN_SPEC_DIR = $(CURDIR)/specs/docusign
DOCUSIGN_SPEC = $(DOCUSIGN_SPEC_DIR)/docusign.yaml
Expand Down Expand Up @@ -386,7 +386,8 @@ okta: target/debug/generator $(OKTA_SPEC)
--spec-link "https://github.com/$(OKTA_SPEC_REPO)" \
--host "na4.okta.net" \
--token-endpoint "account.okta.com/oauth/token" \
--user-consent-endpoint "account.okta.com/oauth/auth" $(EXTRA_ARGS)
--user-consent-endpoint "account.okta.com/oauth/auth" $(EXTRA_ARGS) \
--disclaimer "Okta is a registered trademark of Okta, Inc. and this library has no affiliation with or sponsorship by Okta, Inc."
cargo fmt -p okta
@echo -e "- [Okta](okta/) [![docs.rs](https://docs.rs/okta/badge.svg)](https://docs.rs/okta)" >> README.md

Expand Down
2 changes: 1 addition & 1 deletion docusign/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "docusign"
description = "A fully generated & opinionated API client for the DocuSign API."
version = "0.7.0"
version = "0.7.1"
documentation = "https://docs.rs/docusign/"
repository = "https://github.com/oxidecomputer/third-party-api-clients/tree/main/docusign"
readme = "README.md"
Expand Down
3 changes: 2 additions & 1 deletion docusign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

A fully generated, opinionated API client library for DocuSign.


[![docs.rs](https://docs.rs/docusign/badge.svg)](https://docs.rs/docusign)

## API Details
Expand Down Expand Up @@ -31,7 +32,7 @@ To install the library, add the following to your `Cargo.toml` file.

```toml
[dependencies]
docusign = "0.7.0"
docusign = "0.7.1"
```

## Basic example
Expand Down
3 changes: 2 additions & 1 deletion docusign/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! A fully generated, opinionated API client library for DocuSign.
//!
//!
//! [![docs.rs](https://docs.rs/docusign/badge.svg)](https://docs.rs/docusign)
//!
//! ## API Details
Expand Down Expand Up @@ -29,7 +30,7 @@
//!
//! ```toml
//! [dependencies]
//! docusign = "0.7.0"
//! docusign = "0.7.1"
//! ```
//!
//! ## Basic example
Expand Down
9 changes: 9 additions & 0 deletions generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,7 @@ fn main() -> Result<()> {
opts.reqopt("n", "", "Target Rust crate name", "CRATE");
opts.reqopt("v", "", "Target Rust crate version", "VERSION");
opts.reqopt("d", "", "Target Rust crate description", "DESCRIPTION");
opts.optopt("", "disclaimer", "Disclaimer for README", "DISCLAIMER");
opts.reqopt("", "host", "Target default host", "DEFAULT_HOST");
opts.reqopt(
"",
Expand Down Expand Up @@ -3320,6 +3321,7 @@ fn main() -> Result<()> {
} else {
String::new()
};

let fail = match gen(
&api,
&proper_name,
Expand Down Expand Up @@ -3420,6 +3422,8 @@ rustdoc-args = ["--cfg", "docsrs"]
);
save(&toml, tomlout.as_str())?;

let disclaimer = args.opt_str("disclaimer").unwrap_or_default();

/*
* Generate our documentation for the library.
*/
Expand All @@ -3431,13 +3435,15 @@ rustdoc-args = ["--cfg", "docsrs"]
&proper_name,
host.trim_start_matches("https://"),
&spec_link,
&disclaimer,
),
TemplateType::GenericApiKey => template::generate_docs_generic_api_key(
&api,
&to_snake_case(&name),
&version,
&proper_name,
&spec_link,
&disclaimer,
),
TemplateType::GenericClientCredentials => {
template::generate_docs_generic_client_credentials(
Expand All @@ -3446,6 +3452,7 @@ rustdoc-args = ["--cfg", "docsrs"]
&version,
&proper_name,
&spec_link,
&disclaimer,
)
}
TemplateType::GenericToken => {
Expand All @@ -3458,6 +3465,7 @@ rustdoc-args = ["--cfg", "docsrs"]
&spec_link,
&add_post_header,
&format!("{}::RootProductionServer", to_snake_case(&name)),
&disclaimer,
)
} else {
template::generate_docs_generic_token(
Expand All @@ -3468,6 +3476,7 @@ rustdoc-args = ["--cfg", "docsrs"]
&spec_link,
&add_post_header,
"",
&disclaimer,
)
}
}
Expand Down
16 changes: 12 additions & 4 deletions generator/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ pub fn generate_docs_github(
proper_name: &str,
_host: &str,
spec_link: &str,
disclaimer: &str,
) -> String {
let info = generate_docs_openapi_info(api, proper_name, spec_link, name);
let info = generate_docs_openapi_info(api, proper_name, spec_link, name, disclaimer);
let docs_proper_name = proper_name.to_lowercase();

format!(
Expand Down Expand Up @@ -487,6 +488,7 @@ pub fn generate_docs_openapi_info(
proper_name: &str,
spec_link: &str,
package_name: &str,
disclaimer: &str,
) -> String {
let mut description = String::new();
if let Some(d) = &api.info.description {
Expand Down Expand Up @@ -583,6 +585,7 @@ pub fn generate_docs_openapi_info(

format!(
r#"//! A fully generated, opinionated API client library for {}.
//! {}
//!
//! [![docs.rs](https://docs.rs/{}/badge.svg)](https://docs.rs/{})
//!
Expand All @@ -603,6 +606,7 @@ pub fn generate_docs_openapi_info(
//! along with the code to make this library easy to use.
//! "#,
proper_name,
disclaimer,
to_kebab_case(package_name),
to_kebab_case(package_name),
description,
Expand All @@ -615,6 +619,7 @@ pub fn generate_docs_openapi_info(
)
}

#[allow(clippy::too_many_arguments)]
pub fn generate_docs_generic_token(
api: &openapiv3::OpenAPI,
name: &str,
Expand All @@ -623,8 +628,9 @@ pub fn generate_docs_generic_token(
spec_link: &str,
add_post_header: &str,
server_args: &str,
disclaimer: &str,
) -> String {
let info = generate_docs_openapi_info(api, proper_name, spec_link, name);
let info = generate_docs_openapi_info(api, proper_name, spec_link, name, disclaimer);

let add_post_header_args = if !add_post_header.is_empty() {
format!(
Expand Down Expand Up @@ -755,8 +761,9 @@ pub fn generate_docs_generic_api_key(
version: &str,
proper_name: &str,
spec_link: &str,
disclaimer: &str,
) -> String {
let info = generate_docs_openapi_info(api, proper_name, spec_link, name);
let info = generate_docs_openapi_info(api, proper_name, spec_link, name, disclaimer);
format!(
r#"{}
//!
Expand Down Expand Up @@ -810,8 +817,9 @@ pub fn generate_docs_generic_client_credentials(
version: &str,
proper_name: &str,
spec_link: &str,
disclaimer: &str,
) -> String {
let info = generate_docs_openapi_info(api, proper_name, spec_link, name);
let info = generate_docs_openapi_info(api, proper_name, spec_link, name, disclaimer);
format!(
r#"{}
//!
Expand Down
2 changes: 1 addition & 1 deletion giphy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "giphy-api"
description = "A fully generated & opinionated API client for the Giphy API."
version = "0.7.0"
version = "0.7.1"
documentation = "https://docs.rs/giphy-api/"
repository = "https://github.com/oxidecomputer/third-party-api-clients/tree/main/giphy"
readme = "README.md"
Expand Down
Loading

0 comments on commit 31f85e8

Please sign in to comment.