@lunch-money/v2-api-spec
v2.8.2
Published
OpenAPI specification and version history for the Lunch Money v2 API
Downloads
149
Readme
@lunch-money/v2-api-spec
OpenAPI specification and version history for the Lunch Money v2 API.
Installation
npm install @lunch-money/v2-api-specContents
After installation, the package provides:
- OpenAPI Specification:
node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yaml - Version History:
node_modules/@lunch-money/v2-api-spec/version-history.md
Usage
Accessing the OpenAPI Specification
const fs = require('fs');
const path = require('path');
const specPath = path.join(
__dirname,
'node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yaml'
);
const spec = fs.readFileSync(specPath, 'utf8');Using with OpenAPI Tools
# Generate TypeScript types
npx @openapitools/openapi-generator-cli generate \
-i node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yaml \
-g typescript-axios \
-o ./generated
# Validate the spec
npx swagger-cli validate node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yamlUpdating URLs for Local Development
The package includes a script to help switch between local and production URLs in the OpenAPI specification. This is useful when developing against a local server.
Using the Script
The script is located at node_modules/@lunch-money/v2-api-spec/update-urls.sh.
Required flags:
--local- Switch URLs to local development (default:http://localhost:3000/v2)--production- Switch URLs to production deployment URLs
Switch to production URLs (using defaults):
cd node_modules/@lunch-money/v2-api-spec
./update-urls.sh --productionSwitch to production URLs (with custom URLs):
cd node_modules/@lunch-money/v2-api-spec
API_DEPLOY_URL=https://api.lunchmoney.app/v2 \
DOCS_DEPLOY_URL=https://alpha.lunchmoney.app/v2 \
./update-urls.sh --productionSwitch to local URLs:
cd node_modules/@lunch-money/v2-api-spec
./update-urls.sh --localSwitch to local URLs (with custom local URL):
cd node_modules/@lunch-money/v2-api-spec
LOCAL_URL=http://localhost:4000/v2 ./update-urls.sh --localUsing environment variables:
Create a .env file in the package directory:
LOCAL_URL=http://localhost:3000/v2
API_DEPLOY_URL=https://api.lunchmoney.app/v2
DOCS_DEPLOY_URL=https://alpha.lunchmoney.app/v2Then run:
./update-urls.sh --production
# or
./update-urls.sh --localHow It Works
The script updates the servers section in the OpenAPI specification:
- Server 1: Typically the production API server
- Server 2: Typically a mock or staging server
It also updates any references to these URLs throughout the specification file.
Important Notes
- The script modifies the spec file in place
- Changes are not persisted across
npm install- the package will be restored to its original state - For persistent changes, consider copying the spec to your project directory first
- The script works in both the npm package and the git repository
Versioning
This package follows the Lunch Money API versioning scheme:
- Major version: API version (currently 2)
- Minor version: Number of main endpoint groups
- Revision: Number of updates since last endpoint addition
For example, version 2.8.2 means:
- API version 2
- 8 main endpoint groups
- 2 updates since the 8th endpoint was added
Resources
License
ISC
