Skip to content

Commit

Permalink
Changelog: 16.1.0, describing the changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Dec 26, 2023
1 parent 173ea0f commit d9e78de
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,49 @@

## Version 16

### 16.1.0

- Improving the documentation of endpoints based on middlewares having `security` schema with `type: "input"`.
- According to the OpenAPI specification, endpoints designed to accept some authentication key are expected to
receive it as the request query parameter,
- However `express-zod-api` is designed to combine multiple properties of the `Request` into a single `input` object.
- Those properties are configurable for each method via the `inputSources` config option.
- Therefore, the authentication key for the such middleware can alternatively OR must actually be supplied within
the request body, depending on the API configuration.
- The depiction of security schema as a one expecting the query parameter (due to the limitation of the OpenAPI)
could lead to discrepancies or confusion, so this version offers a solution for that problem.
- Depending on the case, along with the `in` property, either the `x-in-alternative` or `x-in-actual` extension is
added to the security schema depiction, as well as the `description` property explaining the case.

```ts
const authMiddleware = createMiddleware({
security: { type: "input", name: "key" },
});

export const config = createConfig({
inputSources: {
patch: ["body", "query"], // has request body as alternative input source
put: ["body"], // does not have the request query as input source
},
});
```

```yaml
securitySchemes:
FOR_PATCH_REQUEST:
type: apiKey
in: query
name: key
x-in-alternative: body # added
description: key CAN also be supplied within the request body
FOR_PUT_REQUEST:
type: apiKey
in: query # can not be set to "body"
name: key
x-in-actual: body # added
description: key MUST be supplied within the request body instead of query
```
### 16.0.0
- Potentially breaking changes:
Expand Down
4 changes: 4 additions & 0 deletions example/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import express from "express";
import { createConfig } from "../src";

export const config = createConfig({
inputSources: {
patch: ["body", "query"],
put: ["body"],
},
server: {
listen: 8090,
upload: true,
Expand Down

1 comment on commit d9e78de

@RobinTail
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the hell did I change the input sources?
Can not recall this :)

Please sign in to comment.