- Fork the https://github.com/stoplightio/prism repo.
- Git clone your fork (i.e.
git clone https://github.com/<your-username>/prism.git) to your machine. - Run
npm cito install dependencies and setup the project. - Because during the development we run the software directly on top of TypeScript sources, we advise you to use our script:
cd packages/cli && npm run cli -- mock openapi.yaml. - Run
git checkout -b [name_of_your_new_branch]to create a new branch for your work. To help build nicer changelogs, we have a convention for branch names. Please start your branch with eitherfeature/{branch-name},chore/{branch-name}, orfix/{branch-name}. For example, if I was adding a new CLI feature, I would make my branch name:feature/add-cli-new-feature. - Make changes, write code and tests, etc. The fun stuff!
- Run
npm testto test your changes. - Commit your changes.
- Don't forget to
git pushto your branch after you have committed changes.
Now, you are ready to make a pull request to the Stoplight repo! 😃
If this is your first Pull Request on GitHub, here's some help.
We have a pull request template setup that you will fill out when you open your pull request.
We try to respond to all pull requests and issues within 7 days. We welcome feedback from everyone involved in the project in open pull requests.
If you are adding a new devDependency, add it to the root workspace package.json: npm install -D {packageName}.
If you are adding a new runtime dependency, add it to the relevant package.json file (inside of prism-core, prism-http, etc).
Prism has an extensive test suite. To run it, use the regular test script
npm testWe also have an harness test that requires some more setup. In general you do not need to run this on your computer but if you really have nothing better to do, you can run it by executing the following commands:
npm run build.binary
npm run test.harnessThere's a dedicated README.MD file in the test-harness directory in case you want to know what's going on.
The best way to debug a Prism behavior is probably to attach your debugger to the CLI and go from there. To make that happen:
cd packages/cli
npm run cli:debug -- mock file.oas.ymlThe application will wait for a debugger to be attached and break on the first line; from there, you can put your breakpoint here and there and help us debug the software!
fp-ts is the library containing functions and data structures that help Prism lean toward a functional style. It might be annoying to step into its functions; fortunately according to your IDE, you might be able to skip the code. In case you're using Visual Studio Code, you can use the skipFiles section of your launch.json file. You can cobble something like this:
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mock file",
"autoAttachChildProcesses": true,
"skipFiles": ["node_modules/fp-ts/*.js"],
"program": "${workspaceRoot}/packages/cli/src/index.ts",
"args": ["mock", "${input:oasFile}"],
"cwd": "${workspaceRoot}/packages/cli",
"runtimeArgs": ["-r", "ts-node/register/transpile-only", "-r", "tsconfig-paths/register"]
}
]
}- I am receiving weird errors from TypeScript, but I didn't touch any part of the build process!
Prism is using TypeScript's incremental compiler capability that sometimes does not work. The best way to fix the issue is to simply remove any compiled file as well the incremental files:
npm run build -- --cleanFor support questions, please use the Stoplight Community forum. If you are unsure if you are experiencing a bug, the forum is a great place to start.
If you have found a bug, please create an issue.
We try to respond to all pull requests and issues within 7 days.