Skip to content

Commit

Permalink
fix: do not override mock options (#1074)
Browse files Browse the repository at this point in the history
* fix: do not override mock options

* docs: changelog

* test: add

* test: clarify

* changelog: 3.3.3

* v3.3.3
  • Loading branch information
XVincentX authored Apr 2, 2020
1 parent a2f04d5 commit af6bdcc
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
printWidth: 120,
singleQuote: true,
trailingComma: "es5"
trailingComma: "es5",
arrowParens: "avoid"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

# Unreleased

# 3.3.3 (2020-04-02)

## Fixed

- All the dependencies used by the various Prism packages have been explicitily declared avoiding some resolutions problems in case you are using Prism programmatically [#1072](https://github.com/stoplightio/prism/pull/1072)
- Prism's current options aren't overriden internally anymore because of the `Prefer` header set [#1074](https://github.com/stoplightio/prism/pull/1074)


# 3.3.2 (2020-03-16)

Expand Down
6 changes: 4 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"packages": ["packages/*"],
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "3.3.2",
"version": "3.3.3",
"independent": false
}
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@stoplight/prism-cli",
"version": "3.3.2",
"version": "3.3.3",
"author": "Stoplight <support@stoplight.io>",
"bin": {
"prism": "./dist/index.js"
},
"bugs": "https://github.com/stoplightio/prism/issues",
"dependencies": {
"@stoplight/prism-core": "^3.3.2",
"@stoplight/prism-http": "^3.3.2",
"@stoplight/prism-http-server": "^3.3.2",
"@stoplight/prism-core": "^3.3.3",
"@stoplight/prism-http": "^3.3.3",
"@stoplight/prism-http-server": "^3.3.3",
"@stoplight/types": "^11.6.0",
"chalk": "^3.0.0",
"chokidar": "^3.2.1",
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": "3.3.2",
"version": "3.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <support@stoplight.io>",
Expand Down
6 changes: 3 additions & 3 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": "3.3.2",
"version": "3.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <support@stoplight.io>",
Expand All @@ -19,8 +19,8 @@
"access": "public"
},
"dependencies": {
"@stoplight/prism-core": "^3.3.2",
"@stoplight/prism-http": "^3.3.2",
"@stoplight/prism-core": "^3.3.3",
"@stoplight/prism-http": "^3.3.3",
"@stoplight/types": "^11.6.0",
"fast-xml-parser": "^3.12.20",
"fp-ts": "^2.5.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ paths:
type: array
items:
"$ref": "#/components/schemas/Pet"
example:
- name: a_name
photoUrls: []
examples:
a_name:
value: { name: 'clark' }
'401':
description: Authorization information is missing or invalid.
post:
Expand Down
22 changes: 21 additions & 1 deletion packages/http-server/src/__tests__/server.oas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('GET /pet?__server', () => {
}
});

describe('dynamic flag preservation', () => {
describe('Prefer header overrides', () => {
let server: ThenArg<ReturnType<typeof instantiatePrism>>;

beforeAll(async () => {
Expand Down Expand Up @@ -110,6 +110,26 @@ describe('dynamic flag preservation', () => {
it('shuold return two different objects', () => expect(payload).not.toStrictEqual(secondPayload));
});
});

describe('and I send a request with Prefer header selecting a specific example', () => {
describe('and then I send a second request with no prefer header', () => {
let payload: unknown;
let secondPayload: unknown;

beforeAll(async () => {
payload = await fetch(new URL('/no_auth/pets?name=joe', server.address), {
method: 'GET',
headers: { prefer: 'example=a_name' },
}).then(r => r.json());
secondPayload = await fetch(new URL('/no_auth/pets?name=joe', server.address), { method: 'GET' }).then(r =>
r.json()
);
});

it('first object should be the example', () => expect(payload).toHaveProperty('name', 'clark'));
it('second object should be a dynamic object', () => expect(secondPayload).toBeInstanceOf(Array));
});
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/http-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import micri, { Router, json, send, text } from 'micri';
import * as typeIs from 'type-is';
import { getHttpConfigFromRequest } from './getHttpConfigFromRequest';
import { serialize } from './serialize';
import { merge } from 'lodash';
import { merge } from 'lodash/fp';
import { pipe } from 'fp-ts/lib/pipeable';
import * as TE from 'fp-ts/lib/TaskEither';
import * as E from 'fp-ts/lib/Either';
Expand Down
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/prism-http",
"version": "3.3.2",
"version": "3.3.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Stoplight <support@stoplight.io>",
Expand All @@ -20,7 +20,7 @@
"@stoplight/json": "^3.1.2",
"@stoplight/json-ref-readers": "^1.1.1",
"@stoplight/json-ref-resolver": "^3.0.1",
"@stoplight/prism-core": "^3.3.2",
"@stoplight/prism-core": "^3.3.3",
"@stoplight/types": "^11.6.0",
"@stoplight/yaml": "^3.0.2",
"abstract-logging": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,7 @@ format-util@^1.0.3:
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.3.tgz#032dca4a116262a12c43f4c3ec8566416c5b2d95"
integrity sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU=

fp-ts@^2.1.1, fp-ts@^2.5.3:
fp-ts@^2.5.3:
version "2.5.3"
resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-2.5.3.tgz#7f09cc7f3e09623c6ade303d98a2cccdb2cc861f"
integrity sha512-lQd+hahLd8cygNoXbEHDjH/cbF6XVWlEPb8h5GXXlozjCSDxWgclvkpOoTRfBA0P+r69l9VvW1nEsSGIJRQpWw==
Expand Down

0 comments on commit af6bdcc

Please sign in to comment.