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

Error: Invalid ref: #/components/schemas/... #44

Closed
andreas-soroko opened this issue Nov 30, 2022 · 2 comments
Closed

Error: Invalid ref: #/components/schemas/... #44

andreas-soroko opened this issue Nov 30, 2022 · 2 comments

Comments

@andreas-soroko
Copy link

andreas-soroko commented Nov 30, 2022

Hi,

just tried to used it on a existing service and got the error

Error: Invalid ref: #/components/schemas/NameResolutionType2

{
  ref: '#/components/schemas/NameResolutionType2',
  fallbackName: 'nameResolutionType',
  result: 'NameResolutionType2.optional().default("AssetName")'
}

but don't get it, what is wrong.

minimal reproduction example:

{
  "x-generator": "NSwag v13.17.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))",
  "openapi": "3.0.0",
  "info": {
    "title": "title",
    "version": "1.5.0.0"
  },
  "paths": {
    "/api/v2/name-resolution/via-id/{assetId}": {
      "get": {
        "tags": [
          "NameResolutionApi"
        ],
        "operationId": "api_v2_name-resolution_via-id_{assetid}_get_ResolveNamesForAssetV2",
        "parameters": [
          {
            "name": "nameResolutionType",
            "in": "query",
            "schema": {
              "default": "AssetName",
              "oneOf": [
                {
                  "$ref": "#/components/schemas/NameResolutionType2"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "400": {
            "description": ""
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "NameResolutionType2": {
        "type": "string",
        "description": "",
        "x-enumNames": [
          "AssetName",
          "FullName"
        ],
        "enum": [
          "AssetName",
          "FullName"
        ]
      }
    }
  }
}
@astahmer
Copy link
Owner

Hey, my bad it's a regression caused by the chains (.optional().default("AssetName")) following the ref (NameResolutionType2) that I haven't tested, I just published a new version with a fix (v1.4.1)

related commit:
17a7091

@andreas-soroko
Copy link
Author

wow, that was a fast fix - thank you! its working

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

2 participants