Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions example/example.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ interface HeadV1UserRetrievePositiveResponseVariants {
}

/** head /v1/user/retrieve */
type HeadV1UserRetrieveNegativeVariant1 = {
status: "error";
error: {
message: string;
};
};
type HeadV1UserRetrieveNegativeVariant1 = undefined;

/** head /v1/user/retrieve */
interface HeadV1UserRetrieveNegativeResponseVariants {
Expand Down Expand Up @@ -198,7 +193,7 @@ interface HeadV1UserListPositiveResponseVariants {
}

/** head /v1/user/list */
type HeadV1UserListNegativeVariant1 = string;
type HeadV1UserListNegativeVariant1 = undefined;

/** head /v1/user/list */
interface HeadV1UserListNegativeResponseVariants {
Expand Down Expand Up @@ -240,7 +235,7 @@ interface HeadV1AvatarSendPositiveResponseVariants {
}

/** head /v1/avatar/send */
type HeadV1AvatarSendNegativeVariant1 = string;
type HeadV1AvatarSendNegativeVariant1 = undefined;

/** head /v1/avatar/send */
interface HeadV1AvatarSendNegativeResponseVariants {
Expand Down Expand Up @@ -282,7 +277,7 @@ interface HeadV1AvatarStreamPositiveResponseVariants {
}

/** head /v1/avatar/stream */
type HeadV1AvatarStreamNegativeVariant1 = string;
type HeadV1AvatarStreamNegativeVariant1 = undefined;

/** head /v1/avatar/stream */
interface HeadV1AvatarStreamNegativeResponseVariants {
Expand Down Expand Up @@ -395,7 +390,7 @@ interface HeadV1EventsStreamPositiveResponseVariants {
}

/** head /v1/events/stream */
type HeadV1EventsStreamNegativeVariant1 = string;
type HeadV1EventsStreamNegativeVariant1 = undefined;

/** head /v1/events/stream */
interface HeadV1EventsStreamNegativeResponseVariants {
Expand Down
45 changes: 0 additions & 45 deletions example/example.documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,6 @@ paths:
description: HEAD /v1/user/retrieve Positive response
"400":
description: HEAD /v1/user/retrieve Negative response
content:
application/json:
schema:
type: object
properties:
status:
type: string
const: error
error:
type: object
properties:
message:
type: string
required:
- message
additionalProperties: false
required:
- status
- error
additionalProperties: false
examples:
example1:
value:
status: error
error:
message: Sample error message
/v1/user/{id}/remove:
delete:
operationId: DeleteV1UserIdRemove
Expand Down Expand Up @@ -456,13 +430,6 @@ paths:
description: HEAD /v1/user/list Positive response
"400":
description: HEAD /v1/user/list Negative response
content:
text/plain:
schema:
type: string
examples:
example1:
value: Sample error message
/v1/avatar/send:
get:
operationId: GetV1AvatarSend
Expand Down Expand Up @@ -512,10 +479,6 @@ paths:
description: HEAD /v1/avatar/send Positive response
"400":
description: HEAD /v1/avatar/send Negative response
content:
text/plain:
schema:
type: string
/v1/avatar/stream:
get:
operationId: GetV1AvatarStream
Expand Down Expand Up @@ -565,10 +528,6 @@ paths:
description: HEAD /v1/avatar/stream Positive response
"400":
description: HEAD /v1/avatar/stream Negative response
content:
text/plain:
schema:
type: string
/v1/avatar/upload:
post:
operationId: PostV1AvatarUpload
Expand Down Expand Up @@ -790,10 +749,6 @@ paths:
description: HEAD /v1/events/stream Positive response
"400":
description: HEAD /v1/events/stream Negative response
content:
text/plain:
schema:
type: string
/v1/forms/feedback:
post:
operationId: PostV1FormsFeedback
Expand Down
6 changes: 1 addition & 5 deletions express-zod-api/src/common-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
Method,
CORSMethod,
} from "./method";
import { ResponseVariant } from "./api-response";

/** @desc this type does not allow props assignment, but it works for reading them when merged with another interface */
export type EmptyObject = z.output<EmptySchema>;
Expand Down Expand Up @@ -143,7 +142,4 @@ export const isProduction = R.memoizeWith(
() => process.env.NODE_ENV === "production", // eslint-disable-line no-restricted-syntax -- memoized
);

export const doesImplyContent = (
method: ClientMethod,
responseVariant: ResponseVariant,
) => !(method === "head" && responseVariant === "positive");
export const doesImplyContent = (method: ClientMethod) => method !== "head";
2 changes: 1 addition & 1 deletion express-zod-api/src/documentation-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export const depictResponse = ({
statusCode: number;
hasMultipleStatusCodes: boolean;
}): ResponseObject => {
if (!mimeTypes || !doesImplyContent(method, variant)) return { description };
if (!mimeTypes || !doesImplyContent(method)) return { description };
const response = asOAS(
depict(schema, {
rules: { ...brandHandling, ...depicters },
Expand Down
3 changes: 1 addition & 2 deletions express-zod-api/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export class Integration extends IntegrationBase {
(agg, responseVariant) => {
const responses = endpoint.getResponses(responseVariant);
const props = R.chain(([idx, { schema, mimeTypes, statusCodes }]) => {
const hasContent =
mimeTypes && doesImplyContent(method, responseVariant);
const hasContent = mimeTypes && doesImplyContent(method);
const variantType = makeType(
entitle(responseVariant, "variant", `${idx + 1}`),
zodToTs(hasContent ? schema : noContent, ctxOut),
Expand Down
Loading