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

fix: openapi info section #209

Merged
merged 8 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
12 changes: 12 additions & 0 deletions catalyst-gateway/.spectral.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# References to the rules
# OpenAPI: https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#openapi-rules
# OWASP Top 10: https://apistylebook.stoplight.io/docs/owasp-top-10
# Documentations: https://github.com/stoplightio/spectral-documentation/blob/main/src/ruleset.ts

# cspell: words OWASP owasp

# Use CDN hosted version for spectral-documentation and spectral-owasp
extends:
- 'spectral:oas'
- 'https://unpkg.com/@stoplight/[email protected]/dist/ruleset.mjs'
- 'https://unpkg.com/@stoplight/[email protected]/dist/ruleset.mjs'
10 changes: 10 additions & 0 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ test:
BUILD --platform=linux/amd64 ./tests+integration-test
END

# test-lint-openapi - OpenAPI linting from an artifact
# testing whether the OpenAPI generated during build stage follows good practice.
test-lint-openapi:
FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+spectral-base
# Copy the doc artifact.
COPY +hosted-build/doc ./doc
# Scan the doc directory where type of file is JSON.
DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir=./doc --file_type="json"

# Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.)
# publish:
# FROM scratch
Expand All @@ -121,3 +130,4 @@ local-ci-run:
# BUILD +package
BUILD +test
# BUILD +publish

8 changes: 1 addition & 7 deletions catalyst-gateway/bin/src/service/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ fn get_api_contact() -> ContactObject {
.url("https://projectcatalyst.io")
}

/// A summary describing the API
const API_SUMMARY: &str = "Project Catalyst Gateway API";

/// A long description of the API. Markdown is supported
const API_DESCRIPTION: &str = r#"# Catalyst Gateway API.

Expand All @@ -51,9 +48,7 @@ TODO:

/// Get the license details for the API
fn get_api_license() -> LicenseObject {
LicenseObject::new("Apache 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0")
.identifier("Apache-2.0")
LicenseObject::new("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0")
}

/// Get the terms of service for the API
Expand All @@ -72,7 +67,6 @@ pub(crate) fn mk_api(
.contact(get_api_contact())
.description(API_DESCRIPTION)
.license(get_api_license())
.summary(API_SUMMARY)
.terms_of_service(TERMS_OF_SERVICE)
.url_prefix(API_URL_PREFIX.as_str());

Expand Down