RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.8k stars 1.3k forks source link

YamlDotNet.Core.SemanticErrorException #4007

Open vmelamed opened 2 years ago

vmelamed commented 2 years ago

When trying to generate a client from my swagger, I got the exception below. Can you please hint at what might be the problem? Under the exception, I added also the swagger JSON.

YamlDotNet.Core.SemanticErrorException: (Line: 13, Col: 23, Idx: 430) - (Line: 13, Col: 23, Idx: 430): While scanning a multiline plain scalar, found invalid mapping.

Runtime: Default
   at YamlDotNet.Core.Parser.ParseNode(Boolean isBlock, Boolean isIndentlessSequence)
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.TryConsume[T](IParser parser, T& event)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
   at NSwag.OpenApiYamlDocument.<FromYamlAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.Generation.FromDocumentCommand.<RunAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.Generation.FromDocumentCommand.<RunAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.NSwagDocumentBase.<GenerateSwaggerDocumentAsync>d__41.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.NSwagDocument.<ExecuteAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.Document.ExecuteDocumentCommand.<ExecuteDocumentAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.Document.ExecuteDocumentCommand.<RunAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NConsole.CommandLineProcessor.<ProcessSingleAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NConsole.CommandLineProcessor.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.NSwagCommandProcessor.<ProcessAsync>d__3.MoveNext()
{
  "openapi": "3.0.1",
  "info": {
    "title": "External Provisioning API",
    "description": "Provisioning API for use for education and standards examples",
    "contact": {
      "name": "NewCo Software",
      "url": "https://mt.core.platform.newco.com",
      "email": ""
    },
    "version": "v1"
  },
  "paths": {
    "/api/Onboarding/preflight": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Gets the tenant by name.",
        "operationId": "GetPreflightAsync",
        "parameters": [
          {
            "name": "api-version",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Api-Version",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightView"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightView"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightView"
                }
              }
            }
          }
        }
      }
    },
    "/api/Onboarding/onboard": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Gets the tenant by name.",
        "operationId": "ExecuteOnBoardAsync",
        "parameters": [
          {
            "name": "api-version",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Api-Version",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The model.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnboardModel"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/OnboardModel"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/OnboardModel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardView"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardView"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardView"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Job": {
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string",
            "format": "uuid"
          },
          "tenantId": {
            "type": "string",
            "format": "uuid"
          },
          "tenantHostname": {
            "type": "string",
            "nullable": true
          },
          "action": {
            "$ref": "#/components/schemas/ProvisioningAction"
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Service"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "OnboardModel": {
        "type": "object",
        "properties": {
          "tenantId": {
            "type": "string",
            "description": "Gets or sets the tenant identifier.",
            "format": "uuid"
          },
          "tenantHostname": {
            "type": "string",
            "description": "Gets or sets the name.",
            "nullable": true
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Service"
            },
            "description": "Gets or sets the resources.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Onboard model"
      },
      "OnboardView": {
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Onboard view"
      },
      "PreflightView": {
        "type": "object",
        "properties": {
          "job": {
            "$ref": "#/components/schemas/Job"
          }
        },
        "additionalProperties": false,
        "description": "Preflight view"
      },
      "ProvisioningAction": {
        "enum": [
          0,
          1,
          2,
          3
        ],
        "type": "integer",
        "format": "int32"
      },
      "Resource": {
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "$ref": "#/components/schemas/ResourceState"
          },
          "attributes": {
            "type": "object",
            "additionalProperties": { },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ResourceState": {
        "enum": [
          0,
          1,
          2,
          3
        ],
        "type": "integer",
        "format": "int32"
      },
      "Service": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "action": {
            "$ref": "#/components/schemas/ProvisioningAction"
          },
          "state": {
            "$ref": "#/components/schemas/ServiceState"
          },
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Resource"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ServiceState": {
        "enum": [
          0,
          1,
          2
        ],
        "type": "integer",
        "format": "int32"
      }
    }
  }
}
fdellasoppa commented 2 years ago

Same error here. Thanks!

fdellasoppa commented 2 years ago

Found the issue :$ I was referencing the index.html url instead of the swagger.json on NSwagStudio. Specification URL field on the UI.