This repository contains a set of Swift plugins designed to streamline various tasks such as checking for API breakages, validating OpenAPI specifications, and formatting Swift code.
Add the repository as a dependency:
.package(url: "https://github.com/BinaryBirds/swift-plugins", from: "0.0.4"),
Update the packages and you are ready.
To list plugins call swift package plugin --list
This plugin runs a script to check for any breaking changes in the API. It uses the swift package diagnose-api-breaking-changes command to analyze the current API against the last tagged version and reports any breaking changes found.
Usage: swift package --disable-sandbox check-api-breakage
This plugin runs a script to find and report broken symbolic links within the repository. It iterates over all files tracked by Git and checks if their symlink targets exist.
Usage: swift package --disable-sandbox check-broken-symlinks
This plugin checks for local Swift package dependencies in the repository. It scans Package.swift files for local dependencies defined using .package(path:) and reports any occurrences.
Usage: swift package --disable-sandbox check-local-swift-dependencies
This plugin runs a security analysis on the OpenAPI specification using OWASP ZAP. It runs the zap-api-scan.py script inside a Docker container to check for security vulnerabilities in the OpenAPI definition.
Usage: swift package --disable-sandbox check-openapi-security
This plugin validates the OpenAPI specification for compliance with the OpenAPI standard. It uses the openapi-spec-validator tool inside a Docker container to perform the validation.
Usage: swift package --disable-sandbox check-openapi-validation
This plugin checks the codebase for unacceptable language patterns. It uses a predefined list of unacceptable terms and searches the codebase for any matches, reporting them if found.
Usage: swift package --disable-sandbox check-unacceptable-language
This plugin generates a list of contributors for the repository. It uses the git shortlog command to gather commit information and formats it into a CONTRIBUTORS.txt file.
Usage: swift package --disable-sandbox generate-contributors-list
This plugin installs the swift-format tool, the version can be optionally defined using the -v
parameter. The default version is 510.1.0
.
Usage: swift package --disable-sandbox install-swift-format
This plugin installs the Swift OpenAPI generator tool, the version can be optionally defined using the -v
parameter. The default version is 1.2.1
.
Usage: swift package --disable-sandbox install-swift-openapi-generator
It runs chmod
on the .build/plugins
directory to make sure the Bash scripts are executable.
Usage: swift package --disable-sandbox run-chmod
This plugin cleans up build artifacts and other temporary files from the repository.
Usage: swift package --disable-sandbox run-clean
This plugin serves the OpenAPI documentation using an Nginx server. This try to run inside a Docker container.
Optional parameters:
-n
: add a custom identifier for the container, the default isopenapi-server
-p
: add a custom port to bind it to the container, the default is8888:80
Usage: swift package --disable-sandbox run-openapi-server
This plugin checks/formats Swift code using the swift-format tool. It runs the tool on all Swift files in the repository, optionally fixing some of the issues if the --fix
argument is provided.
Usage: swift package --disable-sandbox run-swift-format
for run lint or swift package--disable-sandbox run-swift-format --fix
for fixing
A Makefile is included in this repository to simplify the execution of the plugins. Copy it to the repository where the plugins will be used.