Prerequisite: Clone the API Documentation Generator from GitHub and follow the steps unless the repo for the API Specifications you want to edit doesn't already exist.
Welcome to the Sessions API Specifications repository, the central hub for all specifications and documentation related to Sessions API.
The most critical file here is /public/schema.json
. This file serves as the backbone for our API documentation and specification.
Note: If the API Specifications Generator repo doesn't exist, please follow the instructions in the API Specifications Generator readme.
If the repo already exists, follow these steps:
-
Clone the repository:
git clone <https://github.com/Chillibean/sessions-api>}-specifications.git
-
Install all dependencies by running:
npm install
-
Start the development environment:
npm run dev
This will initiate a development server running on port 5173. Follow the instructions in the terminal. Our setup uses Swagger UI to provide a user-friendly interface for your development needs.
-
Happy Hacking!
Before you start, it's crucial to understand our Versioning and Branches guidelines. We've also provided a Developing Workflow Example to help you understand the development process.
You can bump the versions in package.json
and /public/schema.json
by running:
npm version [<newversion> | major | minor | patch]
The version works as follows:
major
: A major release, which includes breaking changes. (example: removing an endpoint)minor
: A minor release, which includes new features. (example: adding an endpoint)patch
: A patch release, which includes bug fixes. (example: fixing an endpoint)
For a new alpha version, use npm version [version_number]-alpha.0
. Setting an alpha version generates a pre-release that updates and publishes an alpha version of the Client SDK.
main
: The default production branch.- Release branches: These must be named after the release number (e.g.,
1.0.11
,1.1.1
,1.0.2
). - All other branches should originate from a release branch with a descriptive name.
Here's an example of the development workflow:
main
is the default production branch, with the current version as1.0.10
.- You want to add a new endpoint.
- Create a branch from
main
with a new release number, such as1.0.11
. 1.0.11
becomes the release branch.- Create another branch named
task/add-users-endpoint
. - Update
/public/schema.json
to include the new users' endpoint. - Run
npm version 1.0.11-alpha.0
. - Push to GitHub and create a pull request.
- A pre-release is generated, the Client SDK is rebuilt, and the package is published.
- Update your service with the new SDK to test the alpha version.
- If everything works, get approval to merge your branch into the release branch
1.0.11
. - Once ready in
1.0.11
, get approval to merge intomain
. - Merging into
main
generates a release, updates the Client SDK, and publishes a release package. - Update your service with the new
1.0.11
version. - Repeat!
Remember to edit the /public/schema.json
file as needed to reflect the correct updated API specs.
This file is the cornerstone of our repository. It contains all the specs for the Sessions API API.
Key elements within the JSON file:
openapi
: The version of the OpenAPI specification we are using.info
: Information about the API, including its version, title, description, and contact details.tags
: Groupings of API endpoints. More details can be found here.servers
: Defines where the API endpoints can be tested, which is handy for integration with tools like Postman.paths
: Each path should include:summary
: A brief description of the endpoint.operationId
: A unique identifier for the operation (e.g.,getExample
).description
: A more detailed explanation of the operation.parameters
: Lists all required parameters. You can find an example in the auto-generated file.tags
: An array of tags specified above, with each endpoint typically belonging to a single tag.responses
: Each endpoint should have responses defined for 200, 400, 401, 409, and 500 HTTP status codes. You can copy and paste error responses if needed.
You can access the documentation at **https://chillibean.github.io/sessions-api}/**.
The OpenAPI JSON file is available at **https://chillibean.github.io/sessions-api}/schema.json**.
There are two workflows attached to this repository:
deploy.yml
: This workflow handles any branch merged into main
. It automatically triggers a new release with an artifact attached (/public/schema.json
). It also updates and publishes the Client SDK with the latest release and updates GitHub Pages.
push-to-branch.yml
: This workflow manages alpha releases. If a developer sets an alpha release version, it creates an alpha pre-release with an attached artifact (/public/schema.json
). It then triggers the Client SDK to rebuild and publish with the updated alpha pre-release.
enforce-semantic-versioning.yml
: This configuration file serves the purpose of enforcing strict adherence to semantic versioning rules within your project. It ensures that merging into the main branch is only possible when the release branch follows the correct formatting, which includes the major.minor.patch versioning scheme (e.g., 1.0.1, 1.0.2, 3.0.2).
The pre-commit
file validates changes before committing. It checks:
- If the versions in
package.json
and/public/schema.json
match. - Linting in the
/public/schema.json
file.
You can run npm run lint
to check the contents of /public/schema.json
for correctness.
You can run npm run bunlde
to bundle the /public/schema.json
file into the full schema that outputs to /public/fullSchema.json
.
Note: This check is automatically performed before each commit.
- 📄 README.md
- 📄 bump-alpha-version.sh
- 📂 config
- 📄 redocly-config.yml
- 📄 index.html
- 📄 package.json
- 📂 public
- 📄 fullSchema.json
- 📂 refs
- 📂 components
- 📂 responses
- 📄 BadRequest.json
- 📄 Conflict.json
- 📄 InternalServerError.json
- 📄 Unauthorized.json
- 📂 schemas
- 📄 Error.json
- 📄 ExampleResponse.json
- 📂 responses
- 📂 paths
- 📄 example.json
- 📂 components
- 📄 schema.json
- 📂 src
- 📄 App.jsx
- 📄 main.jsx
- 📄 update-openapi-version.js
- 📄 update-version.sh
- 📄 vite.config.js
You can include these file names and descriptions in your README.md section to provide an overview of the files in your repository.
Make sure to enable these settings inside the repository:
General Tab
- Default branch:
main
- Enable "Automatically delete head branches."
Branches Tab
- Require a pull request before merging.
- Require approvals and set the required approvals to 1.
Pages Tab
- Set GitHub Pages visibility to public.
- Source: deploy from a branch.
- Branch:
gh-pages
from the root/
.