From 482f23b506aba84a977900cd46c016d757d329cb Mon Sep 17 00:00:00 2001 From: James Elliott Date: Sun, 12 Mar 2023 09:33:40 +1100 Subject: [PATCH] docs: gen (#5054) --- cmd/authelia-gen/cmd_code.go | 14 +++---- cmd/authelia-gen/types.go | 42 +++++++++++++++++++ cmd/authelia-scripts/cmd/gen.go | 2 +- .../contributing/guidelines/accessibiliy.md | 2 +- .../guides/frequently-asked-questions.md | 2 +- 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/cmd/authelia-gen/cmd_code.go b/cmd/authelia-gen/cmd_code.go index 90d4a9992..2bc0d4af2 100644 --- a/cmd/authelia-gen/cmd_code.go +++ b/cmd/authelia-gen/cmd_code.go @@ -118,14 +118,14 @@ func codeScriptsRunE(cmd *cobra.Command, args []string) (err error) { return err } - if resp, err = http.Get("https://api.github.com/repos/swagger-api/swagger-ui/tags"); err != nil { + if resp, err = http.Get("https://api.github.com/repos/swagger-api/swagger-ui/releases/latest"); err != nil { return fmt.Errorf("failed to get latest version of the Swagger UI: %w", err) } defer resp.Body.Close() var ( - respJSON []GitHubTagsJSON + respJSON GitHubReleasesJSON respRaw []byte ) @@ -137,14 +137,10 @@ func codeScriptsRunE(cmd *cobra.Command, args []string) (err error) { return fmt.Errorf("failed to get latest version of the Swagger UI: %w", err) } - if len(respJSON) < 1 { - return fmt.Errorf("failed to get latest version of the Swagger UI: the api returned zero results") - } - - if strings.HasPrefix(respJSON[0].Name, "v") { - data.VersionSwaggerUI = respJSON[0].Name[1:] + if strings.HasPrefix(respJSON.TagName, "v") { + data.VersionSwaggerUI = respJSON.TagName[1:] } else { - data.VersionSwaggerUI = respJSON[0].Name + data.VersionSwaggerUI = respJSON.TagName } fullPathScriptsGen := filepath.Join(root, pathScriptsGen) diff --git a/cmd/authelia-gen/types.go b/cmd/authelia-gen/types.go index 7f3183a4c..8170bcfc6 100644 --- a/cmd/authelia-gen/types.go +++ b/cmd/authelia-gen/types.go @@ -30,6 +30,48 @@ type GitHubTagsJSON struct { Name string `json:"name"` } +type GitHubReleasesJSON struct { + ID int `json:"id"` + Name string `json:"name"` + TagName string `json:"tag_name"` + TargetCommitISH string `json:"target_commitish"` + NodeID string `json:"node_id"` + Draft bool `json:"draft"` + Prerelease bool `json:"prerelease"` + URL string `json:"url"` + AssetsURL string `json:"assets_url"` + UploadURL string `json:"upload_url"` + HTMLURL string `json:"html_url"` + TarballURL string `json:"tarball_url"` + ZipballURL string `json:"zipball_url"` + Assets []any `json:"assets"` + CreatedAt time.Time `json:"created_at"` + PublishedAt time.Time `json:"published_at"` + Author GitHubAuthorJSON `json:"author"` + Body string `json:"body"` +} + +type GitHubAuthorJSON struct { + ID int `json:"id"` + Login string `json:"login"` + NodeID string `json:"node_id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` +} + // DocsDataMisc represents the docs misc data schema. type DocsDataMisc struct { CSP TemplateCSP `json:"csp"` diff --git a/cmd/authelia-scripts/cmd/gen.go b/cmd/authelia-scripts/cmd/gen.go index 57ce058e6..40cd3c673 100644 --- a/cmd/authelia-scripts/cmd/gen.go +++ b/cmd/authelia-scripts/cmd/gen.go @@ -7,5 +7,5 @@ package cmd const ( - versionSwaggerUI = "4.17.0" + versionSwaggerUI = "4.18.1" ) diff --git a/docs/content/en/contributing/guidelines/accessibiliy.md b/docs/content/en/contributing/guidelines/accessibiliy.md index 1089bc6a1..ba12ce866 100644 --- a/docs/content/en/contributing/guidelines/accessibiliy.md +++ b/docs/content/en/contributing/guidelines/accessibiliy.md @@ -2,7 +2,7 @@ title: "Accessibility" description: "Authelia Development Accessibility Guidelines" lead: "This section covers the accessibility guidelines we aim to respect during development." -date: 2023-03-06T11:42:13+11:00 +date: 2023-03-06T20:17:57+11:00 draft: false images: [] menu: diff --git a/docs/content/en/reference/guides/frequently-asked-questions.md b/docs/content/en/reference/guides/frequently-asked-questions.md index 128a04536..25e0e0588 100644 --- a/docs/content/en/reference/guides/frequently-asked-questions.md +++ b/docs/content/en/reference/guides/frequently-asked-questions.md @@ -2,7 +2,7 @@ title: "Frequently Asked Questions" description: "This guide shows a list of other frequently asked question documents as well as some general ones" lead: "This guide shows a list of other frequently asked question documents as well as some general ones." -date: 2023-03-06T11:04:10+11:00 +date: 2023-03-06T11:32:06+11:00 draft: false images: [] menu: