Skip to content

Commit

Permalink
chore: document types update
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Nov 17, 2024
1 parent c2ee902 commit cebf327
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-dolls-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

fix: export a map of error and response types by status code
4 changes: 2 additions & 2 deletions packages/openapi-ts/src/plugins/@hey-api/services/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getServiceName } from '../../../utils/postprocess';
import { irRef } from '../../../utils/ref';
import { transformServiceName } from '../../../utils/transform';
import type { PluginHandler } from '../../types';
import { operationResponseTransformerRef } from '../transformers/plugin';
import { operationTransformerIrRef } from '../transformers/plugin';
import {
operationOptionsType,
serviceFunctionIdentifier,
Expand Down Expand Up @@ -139,7 +139,7 @@ const requestOptions = ({
const fileTransformers = context.file({ id: 'transformers' });
if (fileTransformers) {
const identifier = fileTransformers.identifier({
$ref: operationResponseTransformerRef({ id: operation.id }),
$ref: operationTransformerIrRef({ id: operation.id, type: 'response' }),

Check warning on line 142 in packages/openapi-ts/src/plugins/@hey-api/services/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@hey-api/services/plugin.ts#L142

Added line #L142 was not covered by tests
namespace: 'value',
});
if (identifier.name) {
Expand Down
22 changes: 6 additions & 16 deletions packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface OperationIRRef {
id: string;
}

const operationTransformerIrRef = ({
export const operationTransformerIrRef = ({
id,
type,
}: OperationIRRef & {
Expand All @@ -46,19 +46,6 @@ const operationTransformerIrRef = ({
})}${affix}`;
};

// TODO: parser - currently unused
export const operationDataTransformerRef = ({ id }: OperationIRRef): string =>
operationTransformerIrRef({ id, type: 'data' });

// TODO: parser - currently unused
export const operationErrorTransformerRef = ({ id }: OperationIRRef): string =>
operationTransformerIrRef({ id, type: 'error' });

export const operationResponseTransformerRef = ({
id,
}: OperationIRRef): string =>
operationTransformerIrRef({ id, type: 'response' });

const schemaIrRef = ({
$ref,
type,
Expand Down Expand Up @@ -394,7 +381,7 @@ export const handler: PluginHandler<Config> = ({ context, plugin }) => {
}

let identifierResponseTransformer = file.identifier({
$ref: operationResponseTransformerRef({ id: operation.id }),
$ref: operationTransformerIrRef({ id: operation.id, type: 'response' }),

Check warning on line 384 in packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts#L384

Added line #L384 was not covered by tests
create: true,
namespace: 'value',
});
Expand Down Expand Up @@ -442,7 +429,10 @@ export const handler: PluginHandler<Config> = ({ context, plugin }) => {
// the created schema response transformer was empty, do not generate
// it and prevent any future attempts
identifierResponseTransformer = file.blockIdentifier({
$ref: operationResponseTransformerRef({ id: operation.id }),
$ref: operationTransformerIrRef({
id: operation.id,
type: 'response',
}),

Check warning on line 435 in packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts#L432-L435

Added lines #L432 - L435 were not covered by tests
namespace: 'value',
});
}
Expand Down

0 comments on commit cebf327

Please sign in to comment.