title: Nswag (asp.net core) --> Typescript (Angular). ModelBinder not binding multipart endpoint
body: <p>I have the following net core 6.0 controller:</p>
  <pre><code>[HttpPost(&quot;/clients/{clientId}/authority-to-release-form&quot;)]
  [ProducesResponseType(200, Type = typeof(long))]
  public async Task Post(long clientId, [FromForm][ModelBinder(BinderType = typeof(JsonModelBinder))]
  AuthorityToReleaseForm form, [FromForm] IFormFile file)
  {
  Ok(form);
  }
  </code></pre>
  <p>Nswag is generating the following Typescript for Angular use:</p>
  <pre><code>    authorityToReleaseForm_Post(clientId: number, form?: AuthorityToReleaseForm | null | undefined, file?: FileParameter | null | undefined): Observable&lt;number&gt; {
      let url_ = this.baseUrl + &quot;/clients/{clientId}/authority-to-release-form&quot;;
      if (clientId=== undefined || clientId=== null)
          throw new Error(&quot;The parameter 'clientId' must be defined.&quot;);
      url_ = url_.replace(&quot;{clientId}&quot;, encodeURIComponent(&quot;&quot; + clientId));
      url_ = url_.replace(/[?&amp;]$/, &quot;&quot;);
  
      const content_ = new FormData();
      if (form !== null &amp;&amp; form !== undefined)
          content_.append(&quot;form&quot;, form.toString());
      if (file !== null &amp;&amp; file !== undefined)
          content_.append(&quot;file&quot;, file.data, file.fileName ? file.fileName : &quot;file&quot;);
  
      let options_ : any = {
          body: content_,
          observe: &quot;response&quot;,
          responseType: &quot;blob&quot;,
          headers: new HttpHeaders({
              &quot;Accept&quot;: &quot;application/json&quot;
          })
      };
  
      return this.http.request(&quot;post&quot;, url_, options_).pipe(_observableMergeMap((response_ : any) =&gt; {
          return this.processAuthorityToReleaseForm_Post(response_);
      })).pipe(_observableCatch((response_: any) =&gt; {
          if (response_ instanceof HttpResponseBase) {
              try {
                  return this.processAuthorityToReleaseForm_Post(&lt;any&gt;response_);
              } catch (e) {
                  return &lt;Observable&lt;number&gt;&gt;&lt;any&gt;_observableThrow(e);
              }
          } else
              return &lt;Observable&lt;number&gt;&gt;&lt;any&gt;_observableThrow(response_);
      }));
  }
  </code></pre>
  <p>The .nswag config file is:</p>
  <pre><code>{
  &quot;runtime&quot;: &quot;Net60&quot;,
  &quot;defaultVariables&quot;: null,
  &quot;documentGenerator&quot;: {
  &quot;webApiToOpenApi&quot;: {
  &quot;controllerNames&quot;: [
  &quot;server.Controllers.AuthorityToReleaseFormController&quot;
  ],
  &quot;isAspNetCore&quot;: true,
  &quot;resolveJsonOptions&quot;: false,
  &quot;defaultUrlTemplate&quot;: &quot;api/{controller}/{id?}&quot;,
  &quot;addMissingPathParameters&quot;: false,
  &quot;includedVersions&quot;: null,
  &quot;defaultPropertyNameHandling&quot;: &quot;Default&quot;,
  &quot;defaultReferenceTypeNullHandling&quot;: &quot;Null&quot;,
  &quot;defaultDictionaryValueReferenceTypeNullHandling&quot;: &quot;NotNull&quot;,
  &quot;defaultResponseReferenceTypeNullHandling&quot;: &quot;NotNull&quot;,
  &quot;defaultEnumHandling&quot;: &quot;Integer&quot;,
  &quot;flattenInheritanceHierarchy&quot;: false,
  &quot;generateKnownTypes&quot;: true,
  &quot;generateEnumMappingDescription&quot;: false,
  &quot;generateXmlObjects&quot;: false,
  &quot;generateAbstractProperties&quot;: false,
  &quot;generateAbstractSchemas&quot;: true,
  &quot;ignoreObsoleteProperties&quot;: false,
  &quot;allowReferencesWithProperties&quot;: false,
  &quot;excludedTypeNames&quot;: [],
  &quot;serviceHost&quot;: null,
  &quot;serviceBasePath&quot;: null,
  &quot;serviceSchemes&quot;: [],
  &quot;infoTitle&quot;: &quot;Server API&quot;,
  &quot;infoDescription&quot;: null,
  &quot;infoVersion&quot;: &quot;1.0.0&quot;,
  &quot;documentTemplate&quot;: null,
  &quot;documentProcessorTypes&quot;: [],
  &quot;operationProcessorTypes&quot;: [],
  &quot;typeNameGeneratorType&quot;: null,
  &quot;schemaNameGeneratorType&quot;: null,
  &quot;contractResolverType&quot;: null,
  &quot;serializerSettingsType&quot;: null,
  &quot;useDocumentProvider&quot;: true,
  &quot;documentName&quot;: &quot;v1&quot;,
  &quot;aspNetCoreEnvironment&quot;: null,
  &quot;createWebHostBuilderMethod&quot;: null,
  &quot;startupType&quot;: null,
  &quot;allowNullableBodyParameters&quot;: true,
  &quot;output&quot;: null,
  &quot;outputType&quot;: &quot;Swagger2&quot;,
  &quot;assemblyPaths&quot;: [
  &quot;bin/Debug/net6.0/server.dll&quot;
  ],
  &quot;assemblyConfig&quot;: null,
  &quot;referencePaths&quot;: [],
  &quot;useNuGetCache&quot;: false
  }
  },
  &quot;codeGenerators&quot;: {
  &quot;openApiToTypeScriptClient&quot;: {
  &quot;className&quot;: &quot;ApiGeneratedService&quot;,
  &quot;moduleName&quot;: &quot;&quot;,
  &quot;namespace&quot;: &quot;&quot;,
  &quot;typeScriptVersion&quot;: 2.7,
  &quot;template&quot;: &quot;Angular&quot;,
  &quot;promiseType&quot;: &quot;Promise&quot;,
  &quot;httpClass&quot;: &quot;HttpClient&quot;,
  &quot;withCredentials&quot;: false,
  &quot;useSingletonProvider&quot;: false,
  &quot;injectionTokenType&quot;: &quot;InjectionToken&quot;,
  &quot;rxJsVersion&quot;: 6.0,
  &quot;dateTimeType&quot;: &quot;Date&quot;,
  &quot;nullValue&quot;: &quot;Null&quot;,
  &quot;generateClientClasses&quot;: true,
  &quot;generateClientInterfaces&quot;: false,
  &quot;generateOptionalParameters&quot;: true,
  &quot;exportTypes&quot;: true,
  &quot;wrapDtoExceptions&quot;: false,
  &quot;exceptionClass&quot;: &quot;ApiException&quot;,
  &quot;clientBaseClass&quot;: null,
  &quot;wrapResponses&quot;: false,
  &quot;wrapResponseMethods&quot;: [],
  &quot;generateResponseClasses&quot;: true,
  &quot;responseClass&quot;: &quot;SwaggerResponse&quot;,
  &quot;protectedMethods&quot;: [],
  &quot;configurationClass&quot;: null,
  &quot;useTransformOptionsMethod&quot;: false,
  &quot;useTransformResultMethod&quot;: false,
  &quot;generateDtoTypes&quot;: true,
  &quot;operationGenerationMode&quot;: &quot;SingleClientFromOperationId&quot;,
  &quot;markOptionalProperties&quot;: true,
  &quot;generateCloneMethod&quot;: false,
  &quot;typeStyle&quot;: &quot;Interface&quot;,
  &quot;classTypes&quot;: [],
  &quot;extendedClasses&quot;: [],
  &quot;extensionCode&quot;: null,
  &quot;generateDefaultValues&quot;: true,
  &quot;excludedTypeNames&quot;: [],
  &quot;excludedParameterNames&quot;: [],
  &quot;handleReferences&quot;: false,
  &quot;generateConstructorInterface&quot;: true,
  &quot;convertConstructorInterfaceData&quot;: false,
  &quot;importRequiredTypes&quot;: true,
  &quot;useGetBaseUrlMethod&quot;: false,
  &quot;baseUrlTokenName&quot;: &quot;API_BASE_URL&quot;,
  &quot;queryNullValue&quot;: &quot;&quot;,
  &quot;inlineNamedDictionaries&quot;: false,
  &quot;inlineNamedAny&quot;: false,
  &quot;templateDirectory&quot;: null,
  &quot;typeNameGeneratorType&quot;: null,
  &quot;propertyNameGeneratorType&quot;: null,
  &quot;enumNameGeneratorType&quot;: null,
  &quot;serviceHost&quot;: null,
  &quot;serviceSchemes&quot;: null,
  &quot;output&quot;: &quot;../client/projects/core-lib/src/lib/app.api.generated.ts&quot;
  }
  }
  }
  </code></pre>
  <p>The problem is, we are posting to a multipart form endpoint (which is using a ModelBinder to bind to the Json model), but the Typescript is not stringifying the model and thus it's not binding.</p>
  <p>ie.
  generated code: <code>content_.append(&quot;form&quot;, form.toString());</code></p>
  <p>would have expected: <code>content_.append(&quot;form&quot;, Json.stringify(form));</code></p>
  <p>We are working around it by passing the form through like this:</p>
  <pre><code>const jsonForm = JSON.stringify(this.model.toForm()) as unknown as AuthorityToReleaseForm; this.api.authorityToReleaseForm_Post(this.clientId, jsonForm, this.file).subscribe();
  </code></pre>
  <p>This works but is pretty hacky.</p>
  <p>Is there any way to get the generated code to stringify the json model data or a nicer work-around?</p>