Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added v22 of keycloak to openapi.jsons, adapted to newer doc versions #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keycloak/21.0.2.json \
keycloak/21.1.0.json \
keycloak/21.1.1.json \
keycloak/21.1.2.json \
keycloak/22.0.0.json \
keycloak/sso-6.json \
keycloak/sso-7.3.json \

Expand Down Expand Up @@ -44,6 +45,7 @@ keycloak/21.0.2.yml \
keycloak/21.1.0.yml \
keycloak/21.1.1.yml \
keycloak/21.1.2.yml \
keycloak/22.0.0.yml \
keycloak/sso-6.yml \
keycloak/sso-7.3.yml \

Expand All @@ -60,6 +62,7 @@ keycloak/21.0.2.html \
keycloak/21.1.0.html \
keycloak/21.1.1.html \
keycloak/21.1.2.html \
keycloak/22.0.0.html \
keycloak/sso-6.html \
keycloak/sso-7.3.html \

Expand Down
11 changes: 9 additions & 2 deletions keycloak-openapi-transformer/src/components/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use scraper::Selector;

lazy_static! {
static ref SCHEMAS_SELECTOR: Selector =
Selector::parse("#models + .sectionbody > .sect2").unwrap();
static ref SCHEMAS_SELECTOR_DEPRECATED: Selector =
Selector::parse("#_definitions + .sectionbody > .sect2").unwrap();
static ref TITLE_SELECTOR: Selector = Selector::parse("h3").unwrap();
static ref ROW_SELECTOR: Selector = Selector::parse("table > tbody > tr").unwrap();
Expand All @@ -16,8 +18,13 @@ lazy_static! {
pub fn parse_schemas(
document: &scraper::html::Html,
) -> IndexMap<String, openapiv3::ReferenceOr<Schema>> {
document
.select(&SCHEMAS_SELECTOR)
let mut tag_sections = document.select(&SCHEMAS_SELECTOR).peekable();

if tag_sections.peek().is_none() {
tag_sections = document.select(&SCHEMAS_SELECTOR_DEPRECATED).peekable();
}

tag_sections
.map(|section| {
(
section
Expand Down
12 changes: 10 additions & 2 deletions keycloak-openapi-transformer/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ mod verb_path;
use verb_path::VerbPath;

lazy_static! {
static ref TAG_SECTION_SELECTOR: Selector =
static ref TAG_SECTION_SELECTOR_DEPRECATED: Selector =
Selector::parse("#_paths + .sectionbody > .sect2").unwrap();
static ref TAG_SECTION_SELECTOR: Selector =
Selector::parse("#_resources + .sectionbody > .sect2").unwrap();
Comment on lines +12 to +15
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is CSS selectors, can we combine them with a comma?

"#_paths + .sectionbody > .sect2, #_resources + .sectionbody > .sect2"


Thank you catching this issue and figuring out the solution. I wasn't even aware Keycloak 22.0.0 had released 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do :)

static ref TAG_TITLE_SELECTOR: Selector = Selector::parse("h3").unwrap();
static ref PATH_SECTION_SELECTOR: Selector = Selector::parse(".sect3").unwrap();
static ref SUMMARY_SELECTOR: Selector = Selector::parse("h4:first-child").unwrap();
Expand All @@ -20,7 +22,13 @@ lazy_static! {
pub fn paths(document: &scraper::html::Html) -> openapiv3::Paths {
let mut paths = openapiv3::Paths::default();

for tag_section in document.select(&TAG_SECTION_SELECTOR) {
let mut tag_sections = document.select(&TAG_SECTION_SELECTOR).peekable();

if tag_sections.peek().is_none() {
tag_sections = document.select(&TAG_SECTION_SELECTOR_DEPRECATED).peekable();
}

for tag_section in tag_sections {
let tag = tag_section
.select(&TAG_TITLE_SELECTOR)
.next()
Expand Down
Loading