Closed dathat closed 1 year ago
I wasted way more time than necessary on this. For anyone stumbling across this issue, updating to swagger-codegen-2.4.32 fixes it.
The SP-API migration guide (https://developer-docs.amazon.com/sp-api/docs/generating-a-java-sdk-with-lwa-token-exchange-and-authentication) links to the older swagger-codegen-2.4.13 version, which caused this issue (and possibly others I've been slowly struggling through).
I'm submitting a...
SP-API Name and Version or Report/Feed Type
The project code generated with swagger for the C# MerchantFulfillmentAPI (using merchantFulfillmentV0.json) does not allow creating addresses to make API requests. The required Address class variables (AddressName, AddressLine1, AddressLine2, etc) do not seem to have methods to initialize them with strings (or anything else) in the generated model files.
Expected Behavior
To construct an address for ShipmentRequestDetails I would expect to do something like:
Address shipFromAddress = new SellingPartnerAPI.MerchantFulfillmentAPI.Model.Address(); shipFromAddress.Name = "My Name"; shipFromAddress.AddressLine1 = "123 Fake St."; ...
Current Behavior
Each variable (Name, AddressLine1, etc) being assigned has an error "Cannot implicitly convert type 'string' to 'SellingPartnerAPI.MerchantFulfillmentAPI.Model.{variable name}'"
Context/Screenshots
There does not appear to be any way to construct or set the value of the field other than empty. Adding three big blocks of code here, sorry for the mess.
1. MerchantFulfillmentAPI.Model.AddressName (to show no string or other input constructor for individual field)
``` /* * Selling Partner API for Merchant Fulfillment * * The Selling Partner API for Merchant Fulfillment helps you build applications that let sellers purchase shipping for non-Prime and Prime orders using Amazon’s Buy Shipping Services. * * OpenAPI spec version: v0 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ using System; using System.Linq; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.ComponentModel.DataAnnotations; using SwaggerDateConverter = SellingPartnerAPI.MerchantFulfillmentAPI.Client.SwaggerDateConverter; namespace SellingPartnerAPI.MerchantFulfillmentAPI.Model { ////// The name of the addressee, or business name. ///
[DataContract] public partial class AddressName : IEquatable/// Initializes a new instance of the class.
///
[JsonConstructorAttribute] public AddressName() { } ////// Returns the string presentation of the object ///
////// Returns the JSON string presentation of the object ///
////// Returns true if objects are equal ///
/// Object to be compared ////// Returns true if AddressName instances are equal ///
/// Instance of AddressName to be compared ////// Gets the hash code ///
////// To validate all properties of the instance ///
/// Validation context ///2. MerchantFulfillmentAPI.Model.Address (to show no string constructor for class)
``` /* * Selling Partner API for Merchant Fulfillment * * The Selling Partner API for Merchant Fulfillment helps you build applications that let sellers purchase shipping for non-Prime and Prime orders using Amazon’s Buy Shipping Services. * * OpenAPI spec version: v0 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ using System; using System.Linq; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.ComponentModel.DataAnnotations; using SwaggerDateConverter = SellingPartnerAPI.MerchantFulfillmentAPI.Client.SwaggerDateConverter; namespace SellingPartnerAPI.MerchantFulfillmentAPI.Model { ////// The postal address information. ///
[DataContract] public partial class Address : IEquatable, IValidatableObject { ////// Initializes a new instance of the class.
///
[JsonConstructorAttribute] protected Address() { } ////// Initializes a new instance of the class.
///
/// name (required). /// addressLine1 (required). /// addressLine2. /// addressLine3. /// districtOrCounty. /// email (required). /// city (required). /// stateOrProvinceCode. /// postalCode (required). /// countryCode (required). /// phone (required). public Address(AddressName name = default(AddressName), AddressLine1 addressLine1 = default(AddressLine1), AddressLine2 addressLine2 = default(AddressLine2), AddressLine3 addressLine3 = default(AddressLine3), DistrictOrCounty districtOrCounty = default(DistrictOrCounty), EmailAddress email = default(EmailAddress), City city = default(City), StateOrProvinceCode stateOrProvinceCode = default(StateOrProvinceCode), PostalCode postalCode = default(PostalCode), CountryCode countryCode = default(CountryCode), PhoneNumber phone = default(PhoneNumber)) { // to ensure "name" is required (not null) if (name == null) { throw new InvalidDataException("name is a required property for Address and cannot be null"); } else { this.Name = name; } // to ensure "addressLine1" is required (not null) if (addressLine1 == null) { throw new InvalidDataException("addressLine1 is a required property for Address and cannot be null"); } else { this.AddressLine1 = addressLine1; } // to ensure "email" is required (not null) if (email == null) { throw new InvalidDataException("email is a required property for Address and cannot be null"); } else { this.Email = email; } // to ensure "city" is required (not null) if (city == null) { throw new InvalidDataException("city is a required property for Address and cannot be null"); } else { this.City = city; } // to ensure "postalCode" is required (not null) if (postalCode == null) { throw new InvalidDataException("postalCode is a required property for Address and cannot be null"); } else { this.PostalCode = postalCode; } // to ensure "countryCode" is required (not null) if (countryCode == null) { throw new InvalidDataException("countryCode is a required property for Address and cannot be null"); } else { this.CountryCode = countryCode; } // to ensure "phone" is required (not null) if (phone == null) { throw new InvalidDataException("phone is a required property for Address and cannot be null"); } else { this.Phone = phone; } this.AddressLine2 = addressLine2; this.AddressLine3 = addressLine3; this.DistrictOrCounty = districtOrCounty; this.StateOrProvinceCode = stateOrProvinceCode; } ////// Gets or Sets Name ///
[DataMember(Name="Name", EmitDefaultValue=false)] public AddressName Name { get; set; } ////// Gets or Sets AddressLine1 ///
[DataMember(Name="AddressLine1", EmitDefaultValue=false)] public AddressLine1 AddressLine1 { get; set; } ////// Gets or Sets AddressLine2 ///
[DataMember(Name="AddressLine2", EmitDefaultValue=false)] public AddressLine2 AddressLine2 { get; set; } ////// Gets or Sets AddressLine3 ///
[DataMember(Name="AddressLine3", EmitDefaultValue=false)] public AddressLine3 AddressLine3 { get; set; } ////// Gets or Sets DistrictOrCounty ///
[DataMember(Name="DistrictOrCounty", EmitDefaultValue=false)] public DistrictOrCounty DistrictOrCounty { get; set; } ////// Gets or Sets Email ///
[DataMember(Name="Email", EmitDefaultValue=false)] public EmailAddress Email { get; set; } ////// Gets or Sets City ///
[DataMember(Name="City", EmitDefaultValue=false)] public City City { get; set; } ////// Gets or Sets StateOrProvinceCode ///
[DataMember(Name="StateOrProvinceCode", EmitDefaultValue=false)] public StateOrProvinceCode StateOrProvinceCode { get; set; } ////// Gets or Sets PostalCode ///
[DataMember(Name="PostalCode", EmitDefaultValue=false)] public PostalCode PostalCode { get; set; } ////// Gets or Sets CountryCode ///
[DataMember(Name="CountryCode", EmitDefaultValue=false)] public CountryCode CountryCode { get; set; } ////// Gets or Sets Phone ///
[DataMember(Name="Phone", EmitDefaultValue=false)] public PhoneNumber Phone { get; set; } ////// Returns the string presentation of the object ///
////// Returns the JSON string presentation of the object ///
////// Returns true if objects are equal ///
/// Object to be compared ////// Returns true if Address instances are equal ///
/// Instance of Address to be compared ////// Gets the hash code ///
////// To validate all properties of the instance ///
/// Validation context ///3. OrdersAPI.Model.Model.Address (to compare how this one allows for string constructors of each variable):
``` /* * Selling Partner API for Orders * * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools. * * OpenAPI spec version: v0 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ using System; using System.Linq; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.ComponentModel.DataAnnotations; using SwaggerDateConverter = SellingPartnerAPI.OrdersAPI.Client.SwaggerDateConverter; namespace SellingPartnerAPI.OrdersAPI.Model { ////// The shipping address for the order. ///
[DataContract] public partial class Address : IEquatable, IValidatableObject { ////// The address type of the shipping address. ///
////// Enum Residential for value: Residential ///
[EnumMember(Value = "Residential")] Residential = 1, ////// Enum Commercial for value: Commercial ///
[EnumMember(Value = "Commercial")] Commercial = 2 } ////// The address type of the shipping address. ///
////// Initializes a new instance of the class.
///
[JsonConstructorAttribute] protected Address() { } ////// Initializes a new instance of the class.
///
/// The name. (required). /// The street address.. /// Additional street address information, if required.. /// Additional street address information, if required.. /// The city . /// The county.. /// The district.. /// The state or region.. /// The municipality.. /// The postal code.. /// The country code. A two-character country code, in ISO 3166-1 alpha-2 format.. /// The phone number. Not returned for Fulfillment by Amazon (FBA) orders.. /// The address type of the shipping address.. public Address(string name = default(string), string addressLine1 = default(string), string addressLine2 = default(string), string addressLine3 = default(string), string city = default(string), string county = default(string), string district = default(string), string stateOrRegion = default(string), string municipality = default(string), string postalCode = default(string), string countryCode = default(string), string phone = default(string), AddressTypeEnum? addressType = default(AddressTypeEnum?)) { // to ensure "name" is required (not null) if (name == null) { throw new InvalidDataException("name is a required property for Address and cannot be null"); } else { this.Name = name; } this.AddressLine1 = addressLine1; this.AddressLine2 = addressLine2; this.AddressLine3 = addressLine3; this.City = city; this.County = county; this.District = district; this.StateOrRegion = stateOrRegion; this.Municipality = municipality; this.PostalCode = postalCode; this.CountryCode = countryCode; this.Phone = phone; this.AddressType = addressType; } ////// The name. ///
////// The street address. ///
////// Additional street address information, if required. ///
////// Additional street address information, if required. ///
////// The city ///
////// The county. ///
////// The district. ///
////// The state or region. ///
////// The municipality. ///
////// The postal code. ///
////// The country code. A two-character country code, in ISO 3166-1 alpha-2 format. ///
////// The phone number. Not returned for Fulfillment by Amazon (FBA) orders. ///
////// Returns the string presentation of the object ///
////// Returns the JSON string presentation of the object ///
////// Returns true if objects are equal ///
/// Object to be compared ////// Returns true if Address instances are equal ///
/// Instance of Address to be compared ////// Gets the hash code ///
////// To validate all properties of the instance ///
/// Validation context ///