Skip to content
Draft
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
6 changes: 6 additions & 0 deletions bin/configs/typescript-fetch-oneOf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ generatorName: typescript-fetch
outputDir: samples/client/petstore/typescript-fetch/builds/oneOf
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-fetch/oneOf.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-fetch
additionalProperties:
npmVersion: 1.0.0
npmName: '@openapitools/typescript-fetch-petstore'
npmRepository: https://skimdb.npmjs.com/registry
snapshot: false

Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
{{#items}}
{{#isDateType}}
if (Array.isArray(json)) {
if (json.every(item => !(isNaN(new Date(json).getTime()))) {
return json.map(value => new Date(json);
if (json.every(item => !(isNaN(new Date(item).getTime())))) {
return json.map(value => new Date(value));
}
}
{{/isDateType}}
{{#isDateTimeType}}
if (Array.isArray(json)) {
if (json.every(item => !(isNaN(new Date(json).getTime()))) {
return json.map(value => new Date(json);
if (json.every(item => !(isNaN(new Date(item).getTime())))) {
return json.map(value => new Date(value));
}
}
{{/isDateTimeType}}
Expand Down Expand Up @@ -188,14 +188,14 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
{{#isDateType}}
if (Array.isArray(value)) {
if (value.every(item => item instanceof Date) {
return value.map(value => value.toISOString().substring(0,10)));
return value.map(value => value.toISOString().substring(0,10));
}
}
{{/isDateType}}
{{#isDateTimeType}}
if (Array.isArray(value)) {
if (value.every(item => item instanceof Date) {
return value.map(value => value.toISOString();
if (value.every(item => item instanceof Date)) {
return value.map(item => item.toISOString());
}
}
{{/isDateTimeType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,17 @@ components:
hunts:
type: boolean
required:
- pet_type
- pet_type

OneOfPrimitiveTypes:
type: object
properties:
value:
oneOf:
- type: boolean
- type: integer
format: int64
- $ref: "#/components/schemas/PetByAge"
- type: array
items:
$ref: "#/components/schemas/PetByAge"
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,16 @@ components:
- "optionTwo"
type: string
required:
- discriminatorField
- discriminatorField
OneOfPrimitiveTypes:
type: object
properties:
value:
oneOf:
- type: boolean
- type: integer
format: int64
- $ref: "#/components/schemas/TestA"
- type: array
items:
$ref: "#/components/schemas/TestA"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ docs/Cat.md
docs/DefaultApi.md
docs/Dog.md
docs/FilePostRequest.md
docs/OneOfPrimitiveTypes.md
docs/OneOfPrimitiveTypesValue.md
docs/PetByAge.md
docs/PetByType.md
docs/PetsFilteredPatchRequest.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export type DogBreedEnum = typeof DogBreedEnum[keyof typeof DogBreedEnum];
export interface FilePostRequest {
'file'?: any;
}
export interface OneOfPrimitiveTypes {
'value'?: OneOfPrimitiveTypesValue;
}
/**
* @type OneOfPrimitiveTypesValue
*/
export type OneOfPrimitiveTypesValue = Array<PetByAge> | PetByAge | boolean | number;

export interface PetByAge {
'age': number;
'nickname'?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# OneOfPrimitiveTypes


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | [**OneOfPrimitiveTypesValue**](OneOfPrimitiveTypesValue.md) | | [optional] [default to undefined]

## Example

```typescript
import { OneOfPrimitiveTypes } from './api';

const instance: OneOfPrimitiveTypes = {
value,
};
```

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OneOfPrimitiveTypesValue


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**age** | **number** | | [default to undefined]
**nickname** | **string** | | [optional] [default to undefined]

## Example

```typescript
import { OneOfPrimitiveTypesValue } from './api';

const instance: OneOfPrimitiveTypesValue = {
age,
nickname,
};
```

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
apis/DefaultApi.ts
apis/index.ts
.gitignore
.npmignore
README.md
docs/DefaultApi.md
docs/OneOfPrimitiveTypes.md
docs/OneOfPrimitiveTypesValue.md
docs/OptionOne.md
docs/OptionTwo.md
docs/TestA.md
docs/TestArrayResponse.md
docs/TestB.md
docs/TestDiscriminatorResponse.md
docs/TestResponse.md
index.ts
models/OptionOne.ts
models/OptionTwo.ts
models/TestA.ts
models/TestArrayResponse.ts
models/TestB.ts
models/TestDiscriminatorResponse.ts
models/TestResponse.ts
models/index.ts
runtime.ts
package.json
src/apis/DefaultApi.ts
src/apis/index.ts
src/index.ts
src/models/OneOfPrimitiveTypes.ts
src/models/OneOfPrimitiveTypesValue.ts
src/models/OptionOne.ts
src/models/OptionTwo.ts
src/models/TestA.ts
src/models/TestArrayResponse.ts
src/models/TestB.ts
src/models/TestDiscriminatorResponse.ts
src/models/TestResponse.ts
src/models/index.ts
src/runtime.ts
tsconfig.json
117 changes: 117 additions & 0 deletions samples/client/petstore/typescript-fetch/builds/oneOf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# @openapitools/typescript-fetch-petstore@1.0.0

A TypeScript SDK client for the localhost API.

## Usage

First, install the SDK from npm.

```bash
npm install @openapitools/typescript-fetch-petstore --save
```

Next, try it out.


```ts
import {
Configuration,
DefaultApi,
} from '@openapitools/typescript-fetch-petstore';
import type { TestRequest } from '@openapitools/typescript-fetch-petstore';

async function example() {
console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
const api = new DefaultApi();

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

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


## Documentation

### API Endpoints

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

| Class | Method | HTTP request | Description
| ----- | ------ | ------------ | -------------
*DefaultApi* | [**test**](docs/DefaultApi.md#test) | **GET** /test |
*DefaultApi* | [**testArray**](docs/DefaultApi.md#testarray) | **GET** /test-array |
*DefaultApi* | [**testDiscriminator**](docs/DefaultApi.md#testdiscriminator) | **GET** /test-discriminator |


### Models

- [OneOfPrimitiveTypes](docs/OneOfPrimitiveTypes.md)
- [OneOfPrimitiveTypesValue](docs/OneOfPrimitiveTypesValue.md)
- [OptionOne](docs/OptionOne.md)
- [OptionTwo](docs/OptionTwo.md)
- [TestA](docs/TestA.md)
- [TestArrayResponse](docs/TestArrayResponse.md)
- [TestB](docs/TestB.md)
- [TestDiscriminatorResponse](docs/TestDiscriminatorResponse.md)
- [TestResponse](docs/TestResponse.md)

### Authorization

Endpoints do not require authorization.


## About

This TypeScript SDK client supports the [Fetch API](https://fetch.spec.whatwg.org/)
and is automatically generated by the
[OpenAPI Generator](https://openapi-generator.tech) project:

- API version: `1.0.0`
- Package version: `1.0.0`
- Generator version: `7.20.0-SNAPSHOT`
- Build package: `org.openapitools.codegen.languages.TypeScriptFetchClientCodegen`

The generated npm module supports the following:

- Environments
* Node.js
* Webpack
* Browserify
- Language levels
* ES5 - you must have a Promises/A+ library installed
* ES6
- Module systems
* CommonJS
* ES6 module system


## Development

### Building

To build the TypeScript source code, you need to have Node.js and npm installed.
After cloning the repository, navigate to the project directory and run:

```bash
npm install
npm run build
```

### Publishing

Once you've built the package, you can publish it to npm:

```bash
npm publish
```

## License

[]()
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ All URIs are relative to *http://localhost:3000*
import {
Configuration,
DefaultApi,
} from '';
import type { TestRequest } from '';
} from '@openapitools/typescript-fetch-petstore';
import type { TestRequest } from '@openapitools/typescript-fetch-petstore';

async function example() {
console.log("🚀 Testing SDK...");
console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
const api = new DefaultApi();

try {
Expand Down Expand Up @@ -79,11 +79,11 @@ No authorization required
import {
Configuration,
DefaultApi,
} from '';
import type { TestArrayRequest } from '';
} from '@openapitools/typescript-fetch-petstore';
import type { TestArrayRequest } from '@openapitools/typescript-fetch-petstore';

async function example() {
console.log("🚀 Testing SDK...");
console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
const api = new DefaultApi();

try {
Expand Down Expand Up @@ -136,11 +136,11 @@ No authorization required
import {
Configuration,
DefaultApi,
} from '';
import type { TestDiscriminatorRequest } from '';
} from '@openapitools/typescript-fetch-petstore';
import type { TestDiscriminatorRequest } from '@openapitools/typescript-fetch-petstore';

async function example() {
console.log("🚀 Testing SDK...");
console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
const api = new DefaultApi();

try {
Expand Down
Loading
Loading