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

Missing schemas with polymorphic openapi #33

Open
sathish-soundarapandian opened this issue Mar 5, 2024 · 0 comments
Open

Missing schemas with polymorphic openapi #33

sathish-soundarapandian opened this issue Mar 5, 2024 · 0 comments

Comments

@sathish-soundarapandian
Copy link

Example openapi spec for reproducing the issue -

openapi: 3.0.3
info:Test API Reference
  version: '1.0'
  description: This is the Open Api Spec 3 for the TEST Service. This is under active development. Beware of the breaking change with respect to the generated code stub.
  contact:
    name: API Support
    email: [email protected]
    url: 'https://test.io/'
servers:
  - url: 'https://app.test.io'
paths:
  '/v1/integrations/{integration}':
    post:
      summary: Create integration
      tags:
        - Integrations
      operationId: create-integration
      responses:
        '201':
          $ref: '#/components/responses/IntegrationResponse'
      x-stoplight:
        id: 7ky8v205wqtp4
      description: Create integration
      security:
        - x-api-key: []
      parameters:
        - $ref: '#/components/parameters/Integration'
        - $ref: '#/components/parameters/AccountHeader'
        - $ref: '#/components/parameters/DryRun'
        - $ref: '#/components/parameters/WriteValidation'
      requestBody:
        $ref: '#/components/requestBodies/IntegrationRequest'
      x-internal: false
components:
  schemas:
    AbstractIntegrationRequest:
      title: AbstractIntegrationRequest
      type: object
      description: Abstract for integration request
      properties:
        request:
          $ref: '#/components/schemas/BaseIntegrationRequest'
      required:
        - request
    BaseIntegrationRequest:
      title: BaseIntegrationRequest
      type: object
      description: Base integration request
      required:
        - type
      discriminator:
        propertyName: type
        mapping:
          git: '#/components/schemas/GitIntegrationRequest'
      properties:
        type:
          type: string
          enum:
            - git
    GitIntegrationRequest:
      title: GitIntegrationRequest
      x-discriminator-value: git
      description: Git Integration Request
      allOf:
        - $ref: '#/components/schemas/BaseIntegrationRequest'
        - type: object
          properties:
            type:
              type: string
              enum:
                - git
            connector_identifier:
              type: string
            read_validation_details:
              $ref: '#/components/schemas/ReadValidationDetails'
            write_validation_details:
              $ref: '#/components/schemas/WriteValidationDetails'
          required:
            - type
            - connector_identifier
    ReadValidationDetails:
      title: ReadValidationDetails
      type: object
      properties:
        file_url:
          type: string
    WriteValidationDetails:
      title: WriteValidationDetails
      type: object
      properties:
        repository:
          type: string
        branch:
          type: string
        path:
          type: string
    ValidationResponse:
      title: ValidationResponse
      type: object
      properties:
        url:
          type: string
        status:
          type: string
        error:
          type: string
        validated:
          type: integer
          format: int64
    AbstractIntegrationResponse:
      title: AbstractIntegrationResponse
      type: object
      properties:
        response:
          $ref: "#/components/schemas/BaseIntegrationResponse"
    BaseIntegrationResponse:
      title: BaseIntegrationResponse
      type: object
      description: Base integration response
      discriminator:
        propertyName: type
        mapping:
          git: '#/components/schemas/GitIntegrationResponse'
      properties:
        type:
          type: string
          enum:
            - git
    GitIntegrationResponse:
      x-discriminator-value: git
      allOf:
        - $ref: "#/components/schemas/BaseIntegrationResponse"
        - type: object
          properties:
            identifier:
              type: string
            name:
              type: string
            connector_identifier:
              type: string
            connector_type:
              type: string
            display_type:
              type: string
            host:
              type: string
            auth_type:
              type: string
            via_delegate:
              type: boolean
            validation:
              $ref: '#/components/schemas/ValidationResponse'
  parameters:
    AccountHeader:
      name: Harness-Account
      in: header
      required: false
      schema:
        type: string
      description: 'Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped.'
    Integration:
      name: integration
      in: path
      description: Integration
      required: true
      schema:
        type: string
        enum:
          - git
    DryRun:
      name: dry_run
      in: query
      required: false
      schema:
        type: boolean
      description: This is used if we need to dry run for integration
    WriteValidation:
      name: write_validation
      in: query
      required: false
      schema:
        type: boolean
      description: This is used if we need to dry run write permission for integration
  requestBodies:
    IntegrationRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AbstractIntegrationRequest'
          examples: { }
      description: Details of Integration Request
  responses:
    IntegrationResponse:
      description: Response for integration
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AbstractIntegrationResponse'
        application/yaml:
          schema:
            $ref: '#/components/schemas/AbstractIntegrationResponse'
  securitySchemes:
    x-api-key:
      name: x-api-key
      type: apiKey
      in: header
tags:
  - name: Integrations
    description: Test Integrations
    x-displayName: Test Integrations

When we try to generate the client code, we have GitIntegrationResponse, ValidationResponse, GitIntegrationRequest, ReadValidationDetails, WriteValidationDetails schemas missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant