Skip to content

Commit

Permalink
Merge branch 'stoplightio:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanashapiro authored Nov 7, 2023
2 parents e907869 + d3ed6de commit 6dd6cd6
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @stoplightio/tacocats
* @stoplightio/bear-claws
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

# Unreleased

# 5.5.1 (2023.10.30)

- fixed issue with int64 [#2420](https://github.com/stoplightio/prism/pull/2420)

# 5.5.0 (2023.10.23)

- added new cli flag `--ignoreExamples` [#2408](https://github.com/stoplightio/prism/pull/2408) - thanks @ilanashapiro for your contribution!
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Learn more in the [hosted Prism documentation](https://docs.stoplight.io/docs/pl

### Self-hosted Prism

Prism is an open-source HTTP server run from the command-line. It provides mocking, request validation, and content negotation. Use it standalone tool or in continuous integration.
Prism is an open-source HTTP server run from the command-line. It provides mocking, request validation, and content negotiation. Use it standalone tool or in continuous integration.

![Demo of Prism Mock Server being called with curl from the CLI](./examples/prism-cli.svg)

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": ["packages/*"],
"npmClient": "yarn",
"version": "5.5.0",
"version": "5.5.1",
"independent": false,
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"sanitize-html": "2.3.3"
},
"devDependencies": {
"@stoplight/types": "^13.15.0",
"@stoplight/types": "^14.0.0",
"@types/caseless": "^0.12.2",
"@types/content-type": "^1.1.5",
"@types/jest": "^29.5.4",
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "@stoplight/prism-cli",
"version": "5.5.0",
"version": "5.5.1",
"author": "Stoplight <[email protected]>",
"bin": {
"prism": "./dist/index.js"
},
"bugs": "https://github.com/stoplightio/prism/issues",
"dependencies": {
"@stoplight/http-spec": "^5.9.2",
"@stoplight/http-spec": "^6.0.2",
"@stoplight/json": "^3.18.1",
"@stoplight/json-schema-ref-parser": "9.2.7",
"@stoplight/prism-core": "^5.5.0",
"@stoplight/prism-http": "^5.5.0",
"@stoplight/prism-http-server": "^5.5.0",
"@stoplight/types": "^13.15.0",
"@stoplight/prism-core": "^5.5.1",
"@stoplight/prism-http": "^5.5.1",
"@stoplight/prism-http-server": "^5.5.1",
"@stoplight/types": "^14.0.0",
"chalk": "^4.1.2",
"chokidar": "^3.5.2",
"fp-ts": "^2.11.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/prism-core",
"version": "5.5.0",
"version": "5.5.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <[email protected]>",
Expand Down
8 changes: 4 additions & 4 deletions packages/http-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/prism-http-server",
"version": "5.5.0",
"version": "5.5.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <[email protected]>",
Expand All @@ -19,9 +19,9 @@
"access": "public"
},
"dependencies": {
"@stoplight/prism-core": "^5.5.0",
"@stoplight/prism-http": "^5.5.0",
"@stoplight/types": "^13.15.0",
"@stoplight/prism-core": "^5.5.1",
"@stoplight/prism-http": "^5.5.1",
"@stoplight/types": "^14.0.0",
"fast-xml-parser": "^4.2.0",
"fp-ts": "^2.11.5",
"io-ts": "^2.2.16",
Expand Down
6 changes: 3 additions & 3 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/prism-http",
"version": "5.5.0",
"version": "5.5.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <[email protected]>",
Expand All @@ -20,8 +20,8 @@
"@stoplight/json": "^3.18.1",
"@stoplight/json-schema-merge-allof": "0.7.8",
"@stoplight/json-schema-sampler": "0.3.0",
"@stoplight/prism-core": "^5.5.0",
"@stoplight/types": "^13.15.0",
"@stoplight/prism-core": "^5.5.1",
"@stoplight/types": "^14.0.0",
"@stoplight/yaml": "^4.2.3",
"abstract-logging": "^2.0.1",
"accepts": "^1.3.7",
Expand Down
10 changes: 5 additions & 5 deletions packages/http/src/mocker/__tests__/HttpMocker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ describe('mocker', () => {
...mockResource,
callbacks: [
{
callbackName: 'c1',
key: 'c1',
method: 'get',
path: 'http://example.com/notify',
id: '1',
responses: [{ id: '200', code: '200', contents: [{ id: 'contents', mediaType: 'application/json' }] }],
},
{
callbackName: 'c2',
key: 'c2',
method: 'get',
path: 'http://example.com/notify2',
id: '2',
Expand All @@ -215,11 +215,11 @@ describe('mocker', () => {
expect(runCallback).toHaveBeenCalledTimes(2);
expect(runCallback).toHaveBeenNthCalledWith(
1,
expect.objectContaining({ callback: expect.objectContaining({ callbackName: 'c1' }) })
expect.objectContaining({ callback: expect.objectContaining({ key: 'c1' }) })
);
expect(runCallback).toHaveBeenNthCalledWith(
2,
expect.objectContaining({ callback: expect.objectContaining({ callbackName: 'c2' }) })
expect.objectContaining({ callback: expect.objectContaining({ key: 'c2' }) })
);
});
});
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('mocker', () => {
},
callbacks: [
{
callbackName: 'callback',
key: 'callback',
method: 'get',
path: 'http://example.com/notify',
id: '1',
Expand Down
6 changes: 3 additions & 3 deletions packages/http/src/mocker/callback/__tests__/callbacks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('runCallback()', () => {

await runCallback({
callback: {
callbackName: 'test callback',
key: 'test callback',
method: 'get',
path: 'http://example.com/{$method}/{$statusCode}/{$response.body#/id}/{$request.header.content-type}',
id: '1',
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('runCallback()', () => {

await runCallback({
callback: {
callbackName: 'test callback',
key: 'test callback',
method: 'get',
path: 'http://example.com/{$method}/{$statusCode}/{$response.body#/id}/{$request.header.content-type}',
id: '1',
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('runCallback()', () => {

await runCallback({
callback: {
callbackName: 'test callback',
key: 'test callback',
method: 'get',
path: 'http://example.com/{$method}/{$statusCode}/{$response.body#/id}/{$request.header.content-type}',
id: '1',
Expand Down
24 changes: 16 additions & 8 deletions packages/http/src/mocker/callback/callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ export function runCallback({
const { url, requestData } = assembleRequest({ resource: callback, request, response });
const logViolation = violationLogger(logger);

logCallbackRequest({ logger, callbackName: callback.callbackName, url, requestData });
logCallbackRequest({ logger, callbackName: callback.key, url, requestData });

return pipe(
TE.tryCatch(() => fetch(url, requestData), E.toError),
TE.chain(parseResponse),
TE.map(callbackResponseLogger({ logger, callbackName: callback.callbackName })),
TE.mapLeft(error =>
logger.error(`${chalk.blueBright(callback.callbackName + ':')} Request failed: ${error.message}`)
),
TE.map(callbackResponseLogger({ logger, callbackName: callback.key })),
TE.mapLeft(error => logger.error(`${chalk.blueBright(callback.key + ':')} Request failed: ${error.message}`)),
TE.chainEitherK(element => {
return pipe(
validateOutput({ resource: callback, element }),
Expand All @@ -52,15 +50,25 @@ export function runCallback({
};
}

function logCallbackRequest({ logger, url, callbackName, requestData }: { logger: Logger, callbackName: string, url: string, requestData: Pick<RequestInit, 'headers' | 'method' | 'body'> }) {
function logCallbackRequest({
logger,
url,
callbackName,
requestData,
}: {
logger: Logger;
callbackName: string;
url: string;
requestData: Pick<RequestInit, 'headers' | 'method' | 'body'>;
}) {
const prefix = `${chalk.blueBright(callbackName + ':')} ${chalk.grey('> ')}`;
logger.info(`${prefix}Executing "${requestData.method}" callback to ${url}...`);
logRequest({ logger, prefix, ...pick(requestData, 'body', 'headers') });
}

function callbackResponseLogger({ logger, callbackName }: { logger: Logger, callbackName: string }) {
function callbackResponseLogger({ logger, callbackName }: { logger: Logger; callbackName: string }) {
const prefix = `${chalk.blueBright(callbackName + ':')} ${chalk.grey('< ')}`;

return (response: IHttpResponse) => {
logger.info(`${prefix}Received callback response`);
logResponse({ logger, prefix, ...pick(response, 'body', 'headers', 'statusCode') });
Expand Down
27 changes: 20 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1364,14 +1364,14 @@
dependencies:
"@sinonjs/commons" "^3.0.0"

"@stoplight/http-spec@^5.9.2":
version "5.9.6"
resolved "https://registry.npmjs.org/@stoplight/http-spec/-/http-spec-5.9.6.tgz"
integrity sha512-3BSNYLwUw/O8wXAeLalyNC6tMeDP7OffX3jiLBzxNKTqGiQJAbnRWdD6wcDqL2EtZLt6FBamHTI5vw9lNvUbew==
"@stoplight/http-spec@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@stoplight/http-spec/-/http-spec-6.0.2.tgz#924e7be225bac3c2a3feec152f9b2671cb174358"
integrity sha512-6uQxW0ycJF3cUSthsv7u3EClGn6AgqkLW9Q0dlrxOYJ1iH5Rx6SJEGYtmnkbTc/iXX/LygyoQ40lk8ebpqSegQ==
dependencies:
"@stoplight/json" "^3.18.1"
"@stoplight/json-schema-generator" "1.0.2"
"@stoplight/types" "^13.15.0"
"@stoplight/types" "14.0.0"
"@types/json-schema" "7.0.11"
"@types/swagger-schema-official" "~2.0.22"
"@types/type-is" "^1.6.3"
Expand All @@ -1381,7 +1381,7 @@
lodash.pickby "^4.6.0"
openapi3-ts "^2.0.2"
postman-collection "^4.1.2"
tslib "^2.3.1"
tslib "^2.6.2"
type-is "^1.6.18"

"@stoplight/[email protected]":
Expand Down Expand Up @@ -1447,7 +1447,15 @@
resolved "https://registry.npmjs.org/@stoplight/path/-/path-1.3.2.tgz"
integrity sha512-lyIc6JUlUA8Ve5ELywPC8I2Sdnh1zc1zmbYgVarhXIp9YeAB0ReeqmGEOWNtlHkbP2DAA1AL65Wfn2ncjK/jtQ==

"@stoplight/types@^13.0.0", "@stoplight/types@^13.15.0", "@stoplight/types@^13.6.0":
"@stoplight/[email protected]", "@stoplight/types@^14.0.0":
version "14.0.0"
resolved "https://registry.yarnpkg.com/@stoplight/types/-/types-14.0.0.tgz#f444490664c2c16d5f06265fcbac8d94a33481e8"
integrity sha512-w7Ejau6TaB7RqR0vWzGJSdmgLEYD2frjgbHPZoxgGQwAq/R8Qh/D9p9Bl9JFdii+YTL5xoDjyX0c1WDRlbMV8g==
dependencies:
"@types/json-schema" "^7.0.4"
utility-types "^3.10.0"

"@stoplight/types@^13.0.0", "@stoplight/types@^13.6.0":
version "13.15.0"
resolved "https://registry.npmjs.org/@stoplight/types/-/types-13.15.0.tgz"
integrity sha512-pBLjVRrWGVd+KzTbL3qrmufSKIEp0UfziDBdt/nrTHPKrlrtVwaHdrrQMcpM23yJDU1Wcg4cHvhIuGtKCT5OmA==
Expand Down Expand Up @@ -7456,6 +7464,11 @@ tslib@^2.4.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410"
integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==

tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz"
Expand Down

0 comments on commit 6dd6cd6

Please sign in to comment.