RicoSuter / NSwag

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

[Error] Can't generate CSharp Client from JSON Schema #3913

Open Kinggrass opened 2 years ago

Kinggrass commented 2 years ago

Am I doing something wrong? Could someone please help?

ERROR:

Newtonsoft.Json.JsonSerializationException: Error setting value to 'ItemsRaw' on 'NJsonSchema.JsonSchemaProperty'. ---> Newtonsoft.Json.JsonSerializationException: Unexpected initial token 'Boolean' when populating object. Expected JSON object or array. Path 'oneOf[0].properties.patches', line 1, position 3238.
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   bei NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   bei NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   bei NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   bei Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   bei Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   bei Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   bei NJsonSchema.JsonSchema.set_ItemsRaw(Object value)
   bei Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   bei NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   bei NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   bei Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   bei Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   bei Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   bei Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   bei NJsonSchema.Infrastructure.JsonSchemaSerialization.FromJson[T](String json, IContractResolver contractResolver)
   bei NJsonSchema.Infrastructure.JsonSchemaSerialization.<FromJsonWithLoaderAsync>d__16`1.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwag.Commands.CodeGeneration.JsonSchemaToOpenApiCommand.<RunAsync>d__9.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwag.Commands.CodeGeneration.JsonSchemaToOpenApiCommand.<RunAsync>d__8.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwag.Commands.NSwagDocumentBase.<GenerateSwaggerDocumentAsync>d__41.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwag.Commands.NSwagDocument.<ExecuteAsync>d__8.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwag.Commands.NSwagDocument.<ExecuteCommandLineAsync>d__9.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei NSwagStudio.ViewModels.DocumentViewModel.<>c__DisplayClass17_0.<<GenerateAsync>b__0>d.MoveNext() in /_/src/NSwagStudio/ViewModels/DocumentViewModel.cs:Zeile 59.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass14_0.<<RunTaskAsync>b__0>d.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei MyToolkit.Mvvm.ViewModelBase.<RunTaskAsync>d__12`1.MoveNext()

INPUT:

  "$schema": "http://json-schema.org/draft-07/schema#",
  "$comment": "JSON Schema describing the document format for JSON Selling Partner Listings Feeds (v2).",
  "title": "Selling Partner Listings Feed (v2)",
  "properties": {
    "header": {
      "title": "Feed Header",
      "description": "Header information about the feed submission.",
      "properties": {
        "sellerId": {
          "title": "Selling Partner Identifier",
          "description": "Identifier for the Selling Partner, such as the Merchant Account or Vendor Code.",
          "type": "string"
        },
        "version": {
          "title": "Feed Version",
          "description": "Version of the JSON Selling Partner Listings Feeds specification used for the feed submission.",
          "const": "2.0",
          "type": "string"
        },
        "issueLocale": {
          "title": "Issue Locale",
          "description": "Locale for issue localization. When not provided, the default language code of the first marketplace is used. Examples: \"en_US\", \"fr_CA\", \"fr_FR\". Localized messages default to \"en_US\" when a localization is not available in the specified locale.",
          "type": "string"
        }
      },
      "required": [
        "sellerId",
        "version"
      ],
      "type": "object"
    },
    "messages": {
      "title": "Feed Messages",
      "description": "Messages containing listings data submissions for the Selling Partner.",
      "minItems": 1,
      "items": {
        "title": "Feed Message",
        "description": "Message containing an individual listings data submission.",
        "properties": {
          "messageId": {
            "title": "Message Identifier",
            "description": "Identifier for the message that is unique within this feed submission. Response messages are correlated to this identifier.",
            "examples": [
              1
            ],
            "type":"integer",
            "minimum":1,
            "maximum": 2147483647
          },
          "sku": {
            "title": "SKU (Stock Keeping Unit)",
            "description": "Selling Partner SKU (stock keeping unit) identifier for the listing. SKU uniquely identifies a listing for a Selling Partner.",
            "examples": [
              "ABC123"
            ],
            "minLength": 1,
            "type": "string"
          },
          "operationType": {
            "title": "Operation Type",
            "description": "Type of operation to perform for the listings data submission in this message. \"UPDATE\" indicates the full set of item attributes are provided and any existing attributes data will be replaced with the provided attributes. \"PARTIAL_UPDATE\" indicates only the provided item attributes will be updated with the provided attribute data. \"PATCH\" indicates the provided JSON Patch operations will be used to update the applicable attributes. \"DELETE\" indicates the listings item will be deleted.",
            "enum": [
              "UPDATE",
              "PARTIAL_UPDATE",
              "PATCH",
              "DELETE"
            ],
            "type": "string"
          },
          "productType": {
            "title": "Amazon Product Type",
            "description": "Amazon product type of the listings data submission in this message.",
            "examples": [
              "LUGGAGE",
              "SHOES"
            ],
            "minLength": 1,
            "type": "string"
          },
          "requirements": {
            "title": "Requirements",
            "description": "Name of the requirements type for the listings data submission in this message. \"LISTING\" indicates requirements inclusive of product facts and sales terms. \"LISTING_PRODUCT_ONLY\" indicates requirements inclusive of product facts only. \"LISTING_OFFER_ONLY\" indicates requirements inclusive of sales terms only.",
            "default": "LISTING",
            "enum": [
              "LISTING",
              "LISTING_PRODUCT_ONLY",
              "LISTING_OFFER_ONLY"
            ],
            "type": "string"
          },
          "attributes": {
            "title": "Listings Item Attributes",
            "description": "Attributes data for the listings data submission.",
            "additionalProperties": true,
            "minProperties": 1,
            "type": "object"
          },
          "patches": {
            "title": "Listings Item JSON Patch Operations",
            "description": "Attributes data in the form of JSON Patch operations to update or delete.",
            "minItems": 1,
            "items": {
              "description": "Individual JSON Patch operation.",
              "properties": {
                "op": {
                  "description": "Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See https://tools.ietf.org/html/rfc6902.",
                  "example": "replace",
                  "enum": [
                    "add",
                    "replace",
                    "delete"
                  ],
                  "type": "string"
                },
                "path": {
                  "description": "JSON Pointer path of the attribute to patch. See https://tools.ietf.org/html/rfc6902.",
                  "example": "/attributes/fulfillment_availability",
                  "type": "string"
                },
                "value": {
                  "description": "JSON value to add, replace, or delete.",
                  "example": [
                    {
                      "fulfillment_channel_code":"DEFAULT",
                      "quantity":10
                    }
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              },
              "required": [
                "op",
                "path"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "messageId",
          "sku",
          "operationType"
        ],
        "oneOf": [
          {
            "$comment": "\"UPDATE\" operations require a \"productType\" and \"attributes\"; \"patches\" are not applicable to \"UPDATE\" operations.",
            "properties": {
              "operationType": {
                "const": "UPDATE",
                "type": "string"
              },
              "patches": false
            },
            "required": [
              "productType",
              "attributes"
            ]
          },
          {
            "$comment": "\"requirements\", \"attributes\", \"productType\", and \"patches\" are not applicable to \"DELETE\" operations.",
            "properties": {
              "operationType": {
                "const": "DELETE",
                "type": "string"
              },
              "requirements": false,
              "attributes": false,
              "productType": false,
              "patches": false
            }
          },
          {
            "$comment": "\"PARTIAL_UPDATE\" operations require a \"productType\" and \"attributes\"; \"requirements\" and \"patches\" are not applicable to \"PARTIAL_UPDATE\" operations.",
            "properties": {
              "operationType": {
                "const": "PARTIAL_UPDATE",
                "type": "string"
              },
              "requirements": false,
              "patches": false
            },
            "required": [
              "productType",
              "attributes"
            ]
          },
          {
            "$comment": "\"PATCH\" operations require a \"productType\" and \"patches\"; \"requirements\" and \"attributes\" are not applicable to \"PATCH\" operations.",
            "properties": {
              "operationType": {
                "const": "PATCH",
                "type": "string"
              },
              "requirements": false,
              "attributes": false
            },
            "required": [
              "productType",
              "patches"
            ]
          }
        ],
        "type": "object"
      },
      "type": "array"
    }
  },
  "required": [
    "header",
    "messages"
  ],
  "type": "object"
}
AshleyBurr commented 2 years ago

I have this issue too. Did you manage to fix it?

Kinggrass commented 2 years ago

I have this issue too. Did you manage to fix it?

Unfortunately not... :( and nobody Else cares here about this error. We switched to CSV feeds like in the old days.

AshleyBurr commented 2 years ago

Oh, not even XML. I am just feeling things out. Might just move the offending declaration and see what happens. Not sure I am going to be using it.. whatever it is.