Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: typescript-fetch
outputDir: samples/client/others/typescript-fetch/additional-properties-in-multipart-issue
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-fetch/additional-properties-in-multipart-issue.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-fetch
additionalProperties:
enumPropertyNaming: "original"
enumUnknownDefaultCase: true
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ export class {{classname}} extends runtime.BaseAPI {
{{/isEnumRef}}
{{^isEnumRef}}
{{^withoutRuntimeChecks}}
{{^isContainer}}
formParams.append('{{baseName}}', new Blob([JSON.stringify({{{dataType}}}ToJSON(requestParameters['{{paramName}}']))], { type: "application/json", }));
{{/isContainer}}
{{#isContainer}}
formParams.append('{{baseName}}', new Blob([JSON.stringify(requestParameters['{{paramName}}'])], { type: "application/json", }));
{{/isContainer}}
{{/withoutRuntimeChecks}}{{#withoutRuntimeChecks}}
formParams.append('{{baseName}}', new Blob([JSON.stringify(requestParameters['{{paramName}}'])], { type: "application/json", }));
{{/withoutRuntimeChecks}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
openapi: 3.0.3
info:
title: Minimal
description: Api to reproduce bug
version: 0.5.1-SNAPSHOT.0
tags:
- name: test
servers:
- url: http://localhost:8080
paths:
"/api/v1/file":
post:
tags:
- file
operationId: createFile
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/FileUploadRequest"
encoding:
documentBytes:
contentType: "*/*"
properties:
contentType: application/json
responses:
"201":
description: File created successfully
components:
schemas:
FileUploadRequest:
type: object
properties:
documentBytes:
type: string
format: binary
documentType:
type: string
structured:
$ref: '#/components/schemas/StructuredType'
properties:
$ref: '#/components/schemas/TypeMap'
required:
- documentBytes
- documentType
- properties
TypeMap:
type: object
additionalProperties:
type: string
StructuredType:
type: object
properties:
someString:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apis/FileApi.ts
apis/index.ts
docs/FileApi.md
docs/StructuredType.md
index.ts
models/StructuredType.ts
models/index.ts
runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.19.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* tslint:disable */
/* eslint-disable */
/**
* Minimal
* Api to reproduce bug
*
* The version of the OpenAPI document: 0.5.1-SNAPSHOT.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
StructuredType,
} from '../models/index';
import {
StructuredTypeFromJSON,
StructuredTypeToJSON,
} from '../models/index';

export interface CreateFileRequest {
documentBytes: Blob;
documentType: string;
properties: { [key: string]: string; };
structured?: StructuredType;
}

/**
*
*/
export class FileApi extends runtime.BaseAPI {

/**
*/
async createFileRaw(requestParameters: CreateFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters['documentBytes'] == null) {
throw new runtime.RequiredError(
'documentBytes',
'Required parameter "documentBytes" was null or undefined when calling createFile().'
);
}

if (requestParameters['documentType'] == null) {
throw new runtime.RequiredError(
'documentType',
'Required parameter "documentType" was null or undefined when calling createFile().'
);
}

if (requestParameters['properties'] == null) {
throw new runtime.RequiredError(
'properties',
'Required parameter "properties" was null or undefined when calling createFile().'
);
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const consumes: runtime.Consume[] = [
{ contentType: 'multipart/form-data' },
];
// @ts-ignore: canConsumeForm may be unused
const canConsumeForm = runtime.canConsumeForm(consumes);

let formParams: { append(param: string, value: any): any };
let useForm = false;
// use FormData to transmit files using content-type "multipart/form-data"
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
formParams = new URLSearchParams();
}

if (requestParameters['documentBytes'] != null) {
formParams.append('documentBytes', requestParameters['documentBytes'] as any);
}

if (requestParameters['documentType'] != null) {
formParams.append('documentType', requestParameters['documentType'] as any);
}

if (requestParameters['structured'] != null) {
formParams.append('structured', new Blob([JSON.stringify(StructuredTypeToJSON(requestParameters['structured']))], { type: "application/json", }));
}

if (requestParameters['properties'] != null) {
formParams.append('properties', new Blob([JSON.stringify(requestParameters['properties'])], { type: "application/json", }));
}


let urlPath = `/api/v1/file`;

const response = await this.request({
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: formParams,
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
*/
async createFile(requestParameters: CreateFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.createFileRaw(requestParameters, initOverrides);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export * from './FileApi';
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# FileApi

All URIs are relative to *http://localhost:8080*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**createFile**](FileApi.md#createfile) | **POST** /api/v1/file | |



## createFile

> createFile(documentBytes, documentType, properties, structured)



### Example

```ts
import {
Configuration,
FileApi,
} from '';
import type { CreateFileRequest } from '';

async function example() {
console.log("🚀 Testing SDK...");
const api = new FileApi();

const body = {
// Blob
documentBytes: BINARY_DATA_HERE,
// string
documentType: documentType_example,
// { [key: string]: string; }
properties: ...,
// StructuredType (optional)
structured: ...,
} satisfies CreateFileRequest;

try {
const data = await api.createFile(body);
console.log(data);
} catch (error) {
console.error(error);
}
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **documentBytes** | `Blob` | | [Defaults to `undefined`] |
| **documentType** | `string` | | [Defaults to `undefined`] |
| **properties** | `{ [key: string]: string; }` | | |
| **structured** | [StructuredType](StructuredType.md) | | [Optional] [Defaults to `undefined`] |

### Return type

`void` (Empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: `multipart/form-data`
- **Accept**: Not defined


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **201** | File created successfully | - |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# StructuredType


## Properties

Name | Type
------------ | -------------
`someString` | string

## Example

```typescript
import type { StructuredType } from ''

// TODO: Update the object below with actual values
const example = {
"someString": null,
} satisfies StructuredType

console.log(example)

// Convert the instance to a JSON string
const exampleJSON: string = JSON.stringify(example)
console.log(exampleJSON)

// Parse the JSON string back to an object
const exampleParsed = JSON.parse(exampleJSON) as StructuredType
console.log(exampleParsed)
```

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
export * from './apis/index';
export * from './models/index';
Loading
Loading