Skip to content

Generating services incorrectly #991

@bhperry

Description

@bhperry

Description

Seems to be generating the ts services incorrectly.

In this screenshot, I have fixed the top service to the correct order (ThrowOnError first). The bottom one is as-generated.
image

Reproducible example or configuration

openapi.config.ts

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

export default defineConfig({
  client: '@hey-api/client-fetch',
  input: "../schemas/generated/routespec.yaml",
  output: {
    format: "prettier",
    lint: "eslint",
    path: "../frontend/src/types/generated/routes",
  },
  types: {
    dates: 'types+transform',
    enums: "javascript",
  },
  exportCore: false,
});

package.json

{
    "name": "openapi-generator",
    "version": "0.1.0",
    "private": true,
    "scripts": {
      "openapi-ts": "openapi-ts"
    },
    "dependencies": {
      "typescript": "^5.x"
    },
    "devDependencies": {
      "@hey-api/openapi-ts": "^0.52.3",
      "eslint": "^8.56.0",
      "prettier": "3.3.3"
    }
  }

generation command

npm run openapi-ts

OpenAPI specification (optional)

info:
  description: Notifications API test
  title: Notifications
  version: 2024.08.28
security:
- bearerAuth: []
paths:
  /api/notifications/subscriptions:
    delete:
      description: Unsubscribe a user from a notification topic
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotificationSubscriptionDelete'
      responses:
        '204':
          description: Ok
        '403':
          description: Access denied
    post:
      description: Subscribe a user to a notification topic
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotificationSubscription'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotificationSubscription'
          description: Ok
        '403':
          description: Access denied
    get:
      description: Retrieve user notification subscriptions
      parameters:
      - in: query
        name: user_id
        schema:
          type: string
          nullable: true
        required: false
      - in: query
        name: topic
        schema:
          type: string
          nullable: true
        required: false
      - in: query
        name: last_key
        schema:
          type: string
          nullable: true
        required: false
      - in: query
        name: max_count
        schema:
          type: integer
          default: 100
          minimum: 1
          maximum: 1000
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotificationSubscriptionsList'
          description: Ok
        '403':
          description: Access denied
openapi: 3.0.2
components:
  schemas:
    NotificationSubscriptionDelete:
      type: object
      properties:
        user_id:
          type: string
          nullable: true
        topic:
          type: string
      required:
      - topic
    NotificationSubscription:
      type: object
      properties:
        id:
          type: string
          readOnly: true
        user_id:
          type: string
          nullable: true
        topic:
          type: string
        options:
          nullable: true
      required:
      - topic
    NotificationSubscriptionsList:
      type: object
      properties:
        subscriptions:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/NotificationSubscription'
        next_last_key:
          type: string
          readOnly: true
          nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

System information (optional)

npm: 9.8.1
node.js: v18.18.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions