Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformers for dates are never executed on request #1738

Open
putnap opened this issue Feb 20, 2025 · 0 comments
Open

Transformers for dates are never executed on request #1738

putnap opened this issue Feb 20, 2025 · 0 comments
Labels
bug 🔥 Something isn't working

Comments

@putnap
Copy link

putnap commented Feb 20, 2025

Description

I have configured openap-ts to transform date fields and transformers are genereated and even supplied to SDK clients, however I am unable to observe the transformers being called. I've modified them to even print to console but nothing happens. I'm actually lost here.

Reproducible example or configuration

Here is my config:

import { defineConfig } from '@hey-api/openapi-ts';
import { defaultPlugins } from '@hey-api/openapi-ts';

export default defineConfig({
  input: 'apps/api/docs/swagger.json',
  output: {
    format: 'prettier',
    lint: 'eslint',
    path: 'libs/api-contracts/src',
  },
  plugins: [
    ...defaultPlugins,
    {
      dates: true,
      name: '@hey-api/transformers',
    },
    '@tanstack/react-query',
    '@hey-api/client-axios',
    {
      name: '@hey-api/sdk',
      transformer: true,
    },
  ],
});

Hopefully this is enough of specification

definitions:
  MachineShiftData:
    properties:
      movement_results:
        items:
          $ref: '#/definitions/MovementResult'
        type: array
    required:
    - movement_results
    type: object
  MovementResult:
    properties:
      created_at:
        format: date-time
        type: string
      id:
        type: string
      machine_id:
        type: string
      result:
        allOf:
        - $ref: '#/definitions/Unit'
        enum:
        - pair
        - left
        - right
        - none
        - closed
      station_id:
        type: string
    required:
    - created_at
    - id
    - machine_id
    - result
    - station_id
    type: object
  Unit:
    enum:
    - pair
    - left
    - right
    - none
    - closed
    type: string
    x-enum-varnames:
    - Pair
    - Left
    - Right
    - None
    - Closed

paths:
  /api/machines/{machineId}/shift-data:
    get:
      consumes:
      - application/json
      parameters:
      - description: Machine Id
        in: path
        name: machineId
        required: true
        type: string
      - description: list movements from date
        in: query
        name: from
        type: string
      - description: list movements to date
        in: query
        name: to
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/MachineShiftData'
      security:
      - oauth: []
      summary: Get shift data for a machine
      tags:
      - machines

And here is the generated code:

export const getApiMachinesByMachineIdRecordings = <
  ThrowOnError extends boolean = false
>(
  options: Options<GetApiMachinesByMachineIdRecordingsData, ThrowOnError>
) => {
  return (options.client ?? _heyApiClient).get<
    GetApiMachinesByMachineIdRecordingsResponse,
    unknown,
    ThrowOnError
  >({
    security: [
      {
        scheme: 'bearer',
        type: 'http',
      },
    ],
    responseTransformer: getApiMachinesByMachineIdRecordingsResponseTransformer,
    url: '/api/machines/{machineId}/recordings',
    ...options,
  });
};

OpenAPI specification (optional)

No response

System information (optional)

@hey-api/openapi-ts v0.64.4
@hey-api/client-axios v0.6.1
Node v22.13.1

@putnap putnap added the bug 🔥 Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant