Skip to content

@angular/common broken since 0.90 #3550

@jonaskuske

Description

@jonaskuske

In @hey-api/openapi-ts 0.89, adding '@angular/common' to the plugin list would generate requests and resources as described in the docs.

Since 0.90 (and its change to the Structure API?), adding the plugin does nothing. The documented default for the httpResources and httpRequests config options is still 'flat', but it behaves as if set to false.

Worse, only httpRequests can be re-enabled by manually setting { name: "@angular/common", httpRequests: 'flat' }.

When you try the same for the httpResources option, { name: "@angular/common", httpResources: 'flat' }, the build breaks:

Error: Symbol is not resolved to a node.

Stack Trace:

Error: Symbol  is not resolved to a node.
    at zt.access (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:3:5662)
    at ii._thunk (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:11:24608)
    at ii.toResult (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:4:11702)
    at ii.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:4:11667)
    at AnalysisContext.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/codegen-core/dist/index.mjs:704:9)
    at hr.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:3:33570)
    at AnalysisContext.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/codegen-core/dist/index.mjs:704:9)
    at Sr.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:4:837)
    at AnalysisContext.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/codegen-core/dist/index.mjs:704:9)
    at Fn.analyze (file:///home/jonaskuske/github.com/jonaskuske/openapi-repro/node_modules/@hey-api/openapi-ts/dist/openApi-BU6F2oHy.mjs:3:14164)

I've added a repro at jonaskuske/openapi-repro

Config

import { defineConfig } from "@hey-api/openapi-ts";
import { fileURLToPath } from "node:url";

export default defineConfig({
  input: "./openapi.json",
  output: {
    path: "./src",
    fileName: { suffix: null },
    indexFile: false,
    tsConfigPath: fileURLToPath(import.meta.resolve("./tsconfig.json")),
  },
  plugins: [
    { name: "@hey-api/sdk" },
    { name: "@hey-api/typescript", enums: "javascript" },
    { name: "@hey-api/client-angular", baseUrl: "/api" },
    { name: "@angular/common", httpRequests: 'flat' },
  ],
});

OpenAPI spec

{
  "openapi": "3.1.0",
  "info": {
    "title": "Repro",
    "description": "repro",
    "contact": {
      "name": "Jonas",
      "email": "mail@example.com"
    },
    "version": "dev"
  },
  "paths": {
    "/examples/": {
      "get": {
        "tags": [
          "Examples"
        ],
        "summary": "Get Examples",
        "operationId": "get_examples",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetExamplesResponse"
                },
                "examples": {
                  "single": {
                    "summary": "single",
                    "description": "The value is available in the frontend as route variant `get_examples:200-json-single`.",
                    "value": {
                      "examples": [
                        {
                          "example_value": "hello world"
                        }
                      ]
                    }
                  },
                  "empty": {
                    "summary": "empty",
                    "description": "The value is available in the frontend as route variant `get_examples:200-json-empty`.",
                    "value": {
                      "examples": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Example": {
        "properties": {
          "example_value": {
            "type": "string",
            "title": "Example Value"
          }
        },
        "type": "object",
        "required": [
          "example_value"
        ],
        "title": "Example"
      },
      "GetExamplesResponse": {
        "properties": {
          "examples": {
            "items": {
              "$ref": "#/components/schemas/Example"
            },
            "type": "array",
            "title": "Examples"
          }
        },
        "type": "object",
        "required": [
          "examples"
        ],
        "title": "GetExamplesResponse"
      }
    }
  }
}

Metadata

Metadata

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