ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
137 stars 56 forks source link

Getting invalid reference error for client/service generation #6698

Open TharmiganK opened 6 days ago

TharmiganK commented 6 days ago

Description:

Getting the following error when try to generate client/service from a valid OpenAPI specification:

ERROR: Invalid reference found null in the schema.

But the client generation happens with default json type.

Steps to reproduce:

Try to generate client/service for this OpenAPI specification:

openapi: 3.0.1
info:
  title: SocialMedia
  version: 0.1.0
servers:
  - url: "http://{server}:{port}/socialMedia/v1"
    variables:
      server:
        default: localhost
      port:
        default: "8080"
paths:
  /admin.user:
    get:
      summary: Get admin user
      operationId: getAdminUser
      responses:
        "200":
          description: Ok
          content:
            application/json:
              schema:
                title: admin.user schema
                type: object
                required:
                  - email
                  - id
                  - name
                properties:
                  id:
                    type: integer
                    format: int64
                  name:
                    type: string
                  email:
                    type: string

Affected Versions:

Ballerina SwanLake Update 9 (2201.9.x)

Note: Identified during the connector generation process for slack: https://github.com/ballerina-platform/module-ballerinax-slack/pull/159#discussion_r1665740917

TharmiganK commented 6 days ago

This issue occurs at the parser level when it does the flattening. The parsed reference look like this:

"$ref" : "admin.user schema"

It should points to a path like this: #/components/schemas/admin.user schema

TharmiganK commented 3 days ago

Created an issue in the parser side: https://github.com/swagger-api/swagger-parser/issues/2109