microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
2.83k stars 194 forks source link

Freeze/Stale when generating client #4653

Open zZHorizonZz opened 4 months ago

zZHorizonZz commented 4 months ago

What are you generating using Kiota, clients or plugins?

Kiota plugin

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

TypeScript

Describe the bug

I'm trying to generate the client based on the specified OpenAPI file, but Kiota freezes when it tries to generate the client.

Expected behavior

Kiota shouldn't freeze. I don't think there's an error with the specifications, as other client generators generate valid clients from my tests.

How to reproduce

Try to generate client via generate command I'm using this:

kiota generate -l typescript -d http://localhost:8080/openapi?format=json -c Client -o ./src/client --co

Your path will be different obviously.

Open API description file

openapi: 3.0.3
info:
  title: api-service API
  version: 0.0.1
tags:
  - name: Environment Management
    description: API for managing environments
  - name: Private Service Management
    description: API for managing private services
  - name: Project Management
    description: API for managing projects
  - name: Proxy Admin Service
    description: API for managing proxy rules
paths:
  /v1/environments/{environment}:
    get:
      tags:
        - Environment Management
      summary: Get Environment
      description: Retrieves a specific environment
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Environment retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
        '404':
          description: Environment not found
      security:
        - SecurityScheme: []
  /v1/environments/{environment}/private-services:
    get:
      tags:
        - Private Service Management
      summary: List Private Services
      description: Lists all private services within the specified environment.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Private services retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PrivateServiceResponse'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
    post:
      tags:
        - Private Service Management
      summary: Create Private Service
      description: Creates a new private service within the specified environment.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrivateService'
      responses:
        '200':
          description: Private service created successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/environments/{environment}/private-services/{service}:
    get:
      tags:
        - Private Service Management
      summary: Get Private Service
      description: Gets the specified private service.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: service
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Private service retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrivateServiceResponse'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
    delete:
      tags:
        - Private Service Management
      summary: Delete Private Service
      description: Deletes the specified private service.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: service
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Private service deleted successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
    patch:
      tags:
        - Private Service Management
      summary: Update Private Service
      description: Updates the specified private service.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: service
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrivateService'
      responses:
        '200':
          description: Private service updated successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/environments/{environment}/private-services/{service}/deploy:
    post:
      tags:
        - Private Service Management
      summary: Is Deployable Image
      description: Checks if the app image is deployable.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: service
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Deployable image check completed
          content:
            application/json:
              schema:
                type: boolean
  /v1/environments/{environment}/proxy:
    post:
      tags:
        - Proxy Admin Service
      summary: Create Proxy Rule
      description: Creates a new proxy rule.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProxyRequest'
      responses:
        '200':
          description: Proxy rule created successfully
          content: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/environments/{environment}/proxy/list/{application}:
    get:
      tags:
        - Proxy Admin Service
      summary: List Proxy Rules
      description: Lists all proxy rules for an application.
      parameters:
        - name: application
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Proxy rules retrieved successfully
          content: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/environments/{environment}/proxy/{proxy}:
    delete:
      tags:
        - Proxy Admin Service
      summary: Delete Proxy Rule
      description: Deletes a proxy rule.
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: proxy
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Proxy rule deleted successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/projects:
    get:
      tags:
        - Project Management
      summary: List Projects
      description: Lists all projects
      responses:
        '200':
          description: Projects retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Project'
    post:
      tags:
        - Project Management
      summary: Create Project
      description: Creates a new project
      responses:
        '200':
          description: Project created successfully
          content:
            application/json: {}
  /v1/projects/{project}:
    get:
      tags:
        - Project Management
      summary: Get Project
      description: Retrieves a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
        '404':
          description: Project not found
      security:
        - SecurityScheme: []
    delete:
      tags:
        - Project Management
      summary: Delete Project
      description: Deletes a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project deleted successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
        '404':
          description: Project not found
      security:
        - SecurityScheme: []
  /v1/projects/{project}/environments:
    get:
      tags:
        - Environment Management
      summary: List Environments
      description: Lists all environments within a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Environments retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Environment'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
        '404':
          description: Project not found
      security:
        - SecurityScheme: []
    post:
      tags:
        - Environment Management
      summary: Create Environment
      description: Creates a new environment within a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Environment created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
        '404':
          description: Project not found
      security:
        - SecurityScheme: []
  /v1/projects/{project}/environments/{environment}:
    delete:
      tags:
        - Environment Management
      summary: Delete Environment
      description: Deletes an environment from a project
      parameters:
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Environment deleted successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/projects/{project}/members:
    get:
      tags:
        - Project Management
      summary: List Project Members
      description: Lists all members for a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project members retrieved successfully
          content:
            application/json: {}
  /v1/projects/{project}/roles:
    get:
      tags:
        - Project Management
      summary: List Project Roles
      description: Lists all roles for a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project roles retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectRole'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
    post:
      tags:
        - Project Management
      summary: Create Project Role
      description: Creates a new role for a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project role created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectRole'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/projects/{project}/roles/{role}:
    delete:
      tags:
        - Project Management
      summary: Delete Project Role
      description: Deletes a role from a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: role
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Project role deleted successfully
          content:
            application/json: {}
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
    patch:
      tags:
        - Project Management
      summary: Update Project Role
      description: Updates a role in a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
        - name: role
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Project role updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectRole'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
  /v1/projects/{project}/skus:
    get:
      tags:
        - Project Management
      summary: List Project SKUs
      description: Lists available SKUs for a project
      parameters:
        - name: project
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
      responses:
        '200':
          description: Project SKUs retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SKU'
        '401':
          description: Not Authorized
        '403':
          description: Not Allowed
      security:
        - SecurityScheme: []
components:
  schemas:
    Action:
      enum:
        - ADMIN
        - READ
        - WRITE
      type: string
    Autoscaling:
      description: Represents autoscaling configuration for a resource
      type: object
      properties:
        uid:
          description: Unique identifier for the autoscaling configuration
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        enabled:
          description: Indicates whether autoscaling is enabled
          type: boolean
        metricType:
          description: The metric type used for autoscaling (e.g., 'cpu')
          type: string
        targetUtilization:
          format: int32
          description: The target utilization percentage for the metric
          type: integer
        minReplicas:
          format: int32
          description: The minimum number of replicas to maintain
          type: integer
        maxReplicas:
          format: int32
          description: The maximum number of replicas allowed
          type: integer
    Container:
      description: Represents a container configuration
      required:
        - sourceRepository
        - image
      type: object
      properties:
        uid:
          description: Unique identifier for the container
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        sourceRepository:
          description: The source repository for the container image
          pattern: \S
          type: string
        image:
          description: The name of the container image
          pattern: \S
          type: string
        cpuAllocation:
          format: float
          description: The CPU allocation for the container
          type: number
        memoryAllocation:
          format: int32
          description: The memory allocation (in MB) for the container
          type: integer
        environmentVariables:
          description: Environment variables for the container
          type: array
          items:
            type: object
            properties:
              name:
                description: The name of the environment variable
                type: string
              value:
                description: The value of the environment variable
                type: string
        ports:
          description: Ports exposed by the container
          type: array
          items:
            type: object
            properties:
              name:
                description: The name of the port (optional)
                type: string
              port:
                format: int32
                description: The port number exposed by the container
                type: integer
              protocol:
                description: The protocol used by the port (TCP or UDP)
                type: string
    CreateProxyRequest:
      type: object
      properties:
        application:
          $ref: '#/components/schemas/UUID'
        port:
          format: int32
          type: integer
    Environment:
      description: Represents an environment within a project
      type: object
      properties:
        uid:
          description: Unique identifier for the environment
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        project:
          description: The project to which this environment belongs
          type: object
          allOf:
            - $ref: '#/components/schemas/Project'
        name:
          description: The name of the environment
          type: string
        description:
          description: The description of the environment
          type: string
        isActive:
          description: Indicates if the environment is active
          type: boolean
        createdAt:
          description: The timestamp when the environment was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: The timestamp when the environment was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        active:
          type: boolean
    LocalDateTime:
      format: date-time
      type: string
      example: '2022-03-10T12:15:50'
    PrivateService:
      description: Represents a private service configuration
      required:
        - name
        - sku
      type: object
      properties:
        uid:
          $ref: '#/components/schemas/UUID'
        environment:
          $ref: '#/components/schemas/Environment'
        name:
          description: Name of the private service
          pattern: \S
          type: string
        sku:
          description: SKU of the private service instance
          pattern: \S
          type: string
        containerEntity:
          description: Container configuration for the private service
          type: object
          allOf:
            - $ref: '#/components/schemas/Container'
        autoscalingEntity:
          description: Autoscaling configuration for the private service
          type: object
          allOf:
            - $ref: '#/components/schemas/Autoscaling'
        createdAt:
          description: Timestamp when the private service was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: Timestamp when the private service was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        deletedAt:
          description: Timestamp when the private service was deleted (if applicable)
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
    PrivateServiceResponse:
      type: object
      properties:
        resource:
          $ref: '#/components/schemas/PrivateService'
        status:
          $ref: '#/components/schemas/ServiceStatus'
    Project:
      description: Represents a project containing environments
      type: object
      properties:
        uid:
          description: Unique identifier for the project
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        name:
          description: Name of the project
          type: string
        description:
          description: Description of the project
          type: string
        purpose:
          description: Purpose of the project
          type: string
        createdBy:
          description: User ID who created the project
          type: string
        baseEnvironment:
          description: Base environment for the project
          type: object
          allOf:
            - $ref: '#/components/schemas/Environment'
        baseRole:
          description: Base role for the project
          type: object
          allOf:
            - $ref: '#/components/schemas/ProjectRole'
        environments:
          description: List of environments associated with the project
          type: array
          items:
            description: Represents an environment within a project
            type: object
            properties:
              uid:
                description: Unique identifier for the environment
                type: string
                allOf:
                  - $ref: '#/components/schemas/UUID'
              project:
                description: The project to which this environment belongs
                type: object
                allOf:
                  - $ref: '#/components/schemas/Project'
              name:
                description: The name of the environment
                type: string
              description:
                description: The description of the environment
                type: string
              isActive:
                description: Indicates if the environment is active
                type: boolean
              createdAt:
                description: The timestamp when the environment was created
                type: string
                allOf:
                  - $ref: '#/components/schemas/LocalDateTime'
              updatedAt:
                description: The timestamp when the environment was last updated
                type: string
                allOf:
                  - $ref: '#/components/schemas/LocalDateTime'
              active:
                type: boolean
        createdAt:
          description: Timestamp when the project was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: Timestamp when the project was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
    ProjectMember:
      description: Represents a member of a project and their assigned role
      type: object
      properties:
        uid:
          description: Unique identifier for the project member entry
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        project:
          description: The project to which this member belongs
          type: object
          allOf:
            - $ref: '#/components/schemas/Project'
        member:
          description: The user ID of the project member
          type: string
        role:
          description: The role assigned to the project member
          type: object
          allOf:
            - $ref: '#/components/schemas/ProjectRole'
    ProjectRole:
      description: Represents a role within a project with associated permissions
      type: object
      properties:
        uid:
          description: Unique identifier for the project role
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        project:
          description: The project to which this role belongs
          type: object
          allOf:
            - $ref: '#/components/schemas/Project'
        name:
          description: Unique name of the role
          type: string
        displayName:
          description: Display name of the role (for user interfaces)
          type: string
        description:
          description: Description of the role's purpose
          type: string
        permissions:
          description: List of permissions associated with the role
          type: array
          items:
            type: object
            properties:
              api:
                type: string
              actions:
                type: array
                items:
                  $ref: '#/components/schemas/Action'
        createdBy:
          description: User ID who created the role
          type: string
        createdAt:
          description: Timestamp when the role was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: Timestamp when the role was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
    ProxyRuleEntity:
      type: object
      properties:
        uid:
          $ref: '#/components/schemas/UUID'
        environment:
          $ref: '#/components/schemas/Environment'
        externalPort:
          format: int32
          type: integer
        targetApplicationId:
          $ref: '#/components/schemas/UUID'
        targetApplicationPort:
          format: int32
          type: integer
    SKU:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        family:
          type: string
        cpu:
          format: float
          type: number
        memory:
          format: int32
          type: integer
        price:
          format: float
          type: number
    ServiceStatus:
      type: object
      properties:
        uid:
          type: string
        environment:
          type: string
        state:
          $ref: '#/components/schemas/State'
        message:
          type: string
        currentReplicas:
          format: int32
          type: integer
        lastHeartbeat:
          $ref: '#/components/schemas/LocalDateTime'
    State:
      enum:
        - ERROR
        - WARNING
        - SUCCESS
        - INFO
        - STOPPED
        - PENDING
        - IN_PROGRESS
        - LOADING
      type: string
    UUID:
      format: uuid
      pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
      type: string
  securitySchemes:
    SecurityScheme:
      type: http
      description: Authentication
      scheme: bearer
      bearerFormat: Opaque

Kiota Version

1.14.0+fc4b39c65d89f7bfc8c7f1813c197e95e206da09

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

Debug output

Click to expand log ``` Warning: the TypeScript language is in preview (Preview) some features are not fully supported and source breaking changes will happen with future updates. info: Kiota.Builder.KiotaBuilder[0] Cleaning output directory dbug: Kiota.Builder.KiotaBuilder[0] kiota version 1.14.0 dbug: Kiota.Builder.KiotaBuilder[0] cache file C:\Users\daniel\AppData\Local\Temp\kiota\cache\generation\69C78F8D208172ABCCFD4741296BF1D28E5AECEC57EA6730F0559615D9FF23D5\openapi not found, downloading from http://localhost:8080/openapi?format=json info: Kiota.Builder.KiotaBuilder[0] skipping cache write for URI http://localhost:8080/openapi?format=json as it is a loopback address info: Kiota.Builder.KiotaBuilder[0] loaded description from remote source dbug: Kiota.Builder.KiotaBuilder[0] step 1 - reading the stream - took 00:00:02.1362970 warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/ - A servers entry (v3) or host + basePath + schemes properties (v2) was not present in the OpenAPI description. The root URL will need to be set manually with the request adapter. dbug: Kiota.Builder.KiotaBuilder[0] step 2 - parsing the document - took 00:00:00.1707046 dbug: Kiota.Builder.KiotaBuilder[0] step 3 - updating generation configuration from kiota extension - took 00:00:00.0001302 dbug: Kiota.Builder.KiotaBuilder[0] step 4 - filtering API paths with patterns - took 00:00:00.0050800 warn: Kiota.Builder.KiotaBuilder[0] No server url found in the OpenAPI document. The base url will need to be set when using the client. dbug: Kiota.Builder.KiotaBuilder[0] step 5 - checking whether the output should be updated - took 00:00:00.0200458 dbug: Kiota.Builder.KiotaBuilder[0] step 6 - create uri space - took 00:00:00.0053731 dbug: Kiota.Builder.KiotaBuilder[0] InitializeInheritanceIndex 00:00:00.0035627 ```

Other information

I have tried this on 2 devices on one device kiota is installed via dotnet on second I have binaries added in path and both have same version.

zZHorizonZz commented 4 months ago

The core problem seems to be with GET requests that lack parameters. In those cases, this behavior occurs, as you can see here:

/v1/projects:
    get:
      tags:
        - Project Management
      summary: List Projects
      description: Lists all projects
      responses:
        '200':
          description: Projects retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Project'
baywet commented 4 months ago

Hi @zZHorizonZz Thanks for using kiota and for reaching out. Here is a minimal repro that works, and uncommenting the baseEnvironment, baseRole and environments properties makes the issue appear.

openapi: 3.0.3
info:
  title: api-service API
  version: 0.0.1
  description: API for managing environments, projects, and private services
  contact:
    name: API Support
    email: api@support.com
servers:
  - url: http://localhost:8080
    description: Local server
tags:
  - name: Environment Management
    description: API for managing environments
  - name: Private Service Management
    description: API for managing private services
  - name: Project Management
    description: API for managing projects
  - name: Proxy Admin Service
    description: API for managing proxy rules
paths:
  /v1/projects:
    get:
      operationId: listProjects
      tags:
        - Project Management
      summary: List Projects
      description: Lists all projects
      responses:
        '200':
          description: Projects retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Project'
components:
  schemas:
    Action:
      enum:
        - ADMIN
        - READ
        - WRITE
      type: string
    Environment:
      description: Represents an environment within a project
      type: object
      properties:
        uid:
          description: Unique identifier for the environment
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        project:
          description: The project to which this environment belongs
          type: object
          allOf:
            - $ref: '#/components/schemas/Project'
        name:
          description: The name of the environment
          type: string
        description:
          description: The description of the environment
          type: string
        isActive:
          description: Indicates if the environment is active
          type: boolean
        createdAt:
          description: The timestamp when the environment was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: The timestamp when the environment was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        active:
          type: boolean
    LocalDateTime:
      format: date-time
      type: string
      example: '2022-03-10T12:15:50'
    Project:
      description: Represents a project containing environments
      type: object
      properties:
        uid:
          description: Unique identifier for the project
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        name:
          description: Name of the project
          type: string
        description:
          description: Description of the project
          type: string
        purpose:
          description: Purpose of the project
          type: string
        createdBy:
          description: User ID who created the project
          type: string
        # baseEnvironment:
        #   description: Base environment for the project
        #   type: object
        #   allOf:
        #     - $ref: '#/components/schemas/Environment'
        # baseRole:
        #   description: Base role for the project
        #   type: object
        #   allOf:
        #     - $ref: '#/components/schemas/ProjectRole'
        # environments:
        #   description: List of environments associated with the project
        #   type: array
        #   items:
        #     description: Represents an environment within a project
        #     type: object
        #     properties:
        #       uid:
        #         description: Unique identifier for the environment
        #         type: string
        #         allOf:
        #           - $ref: '#/components/schemas/UUID'
        #       project:
        #         description: The project to which this environment belongs
        #         type: object
        #         allOf:
        #           - $ref: '#/components/schemas/Project'
        #       name:
        #         description: The name of the environment
        #         type: string
        #       description:
        #         description: The description of the environment
        #         type: string
        #       isActive:
        #         description: Indicates if the environment is active
        #         type: boolean
        #       createdAt:
        #         description: The timestamp when the environment was created
        #         type: string
        #         allOf:
        #           - $ref: '#/components/schemas/LocalDateTime'
        #       updatedAt:
        #         description: The timestamp when the environment was last updated
        #         type: string
        #         allOf:
        #           - $ref: '#/components/schemas/LocalDateTime'
        #       active:
        #         type: boolean
        createdAt:
          description: Timestamp when the project was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: Timestamp when the project was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
    ProjectRole:
      description: Represents a role within a project with associated permissions
      type: object
      properties:
        uid:
          description: Unique identifier for the project role
          type: string
          allOf:
            - $ref: '#/components/schemas/UUID'
        project:
          description: The project to which this role belongs
          type: object
          allOf:
            - $ref: '#/components/schemas/Project'
        name:
          description: Unique name of the role
          type: string
        displayName:
          description: Display name of the role (for user interfaces)
          type: string
        description:
          description: Description of the role's purpose
          type: string
        permissions:
          description: List of permissions associated with the role
          type: array
          items:
            type: object
            properties:
              api:
                type: string
              actions:
                type: array
                items:
                  $ref: '#/components/schemas/Action'
        createdBy:
          description: User ID who created the role
          type: string
        createdAt:
          description: Timestamp when the role was created
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
        updatedAt:
          description: Timestamp when the role was last updated
          type: string
          allOf:
            - $ref: '#/components/schemas/LocalDateTime'
    UUID:
      format: uuid
      pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
      type: string
  securitySchemes:
    SecurityScheme:
      type: http
      description: Authentication
      scheme: bearer
      bearerFormat: Opaque

This description is causing a stackoverflow due to circular references. Even if kiota could generate the code, it's most likely that compilers in most languages would complain about the result. This description seems auto-generated, you should look into tweaking the generation so it does not produce circular references.

zZHorizonZz commented 4 months ago

After a closer look, I noticed this as well basically I'm generating OpenAPI specs based on a database model that includes references to other models. This is valid for me, as these models are retrieved lazily from database to prevent an infinite loop. However, I understand why this could be an issue in OpenAPI.

Still, I think the "freeze/stale" behavior is inappropriate in this case, as the user doesn't know what happened. If there's schema validation, perhaps the generate command could throw an error. Otherwise, a timeout with details about the cause might be helpful.

baywet commented 4 months ago

The "freeze" is caused by a stackoverflow, itself caused by infinite recursion of the engine. It is strange however that you're experiencing a freeze behaviour, I get an exception. Reliably detecting the loop (without causing false positives) ahead of time would be extremely difficult/costly. We could catch the stack overflow exception and display a better message as a first stopgap, but that assumes the exception gets thrown. I'm curious to why you don't get an exception? Any specific setup? Did you download the executable manually or are you using dotnet tool?

zZHorizonZz commented 4 months ago

This issue occurs both with the executable on my work PC and with the dotnet tool command on my private PC. I don't recall if I tested it via a regular command prompt, but I have a script defined in my package.json file. After running yarn generate, it executes the command:

"scripts": {
    "generate": "kiota generate -l typescript -d http://localhost:8080/openapi?format=json -c Client -o ./src/client --co",
    "type-check": "tsc --noEmit"
  },

Though the behavior seems normal meaning if there is an error, it is shown in the console the output appears the same as if I executed a regular command.

baywet commented 4 months ago

ah, it might be the environment host for node script runner that's not bubbling up the exception for some reason. Can you test with the command directly on the same machines with the same descriptions to see if you get and exception/terminal execution?

zZHorizonZz commented 4 months ago

I tried this in both the terminal and PowerShell, and the result is the same. I waited for five minutes to see if any errors would be thrown, but it's still stuck on InitializeInheritanceIndex.

https://github.com/microsoft/kiota/assets/60035933/1039d7a1-9932-469d-927f-761961ec0eb0