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
6 changes: 6 additions & 0 deletions bin/configs/typescript-fetch-kebab-case.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generatorName: typescript-fetch
outputDir: samples/client/petstore/typescript-fetch/builds/kebab-case
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-fetch
additionalProperties:
fileNaming: kebab-case
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@ private void addOperationModelImportInformation(OperationsMap operations) {
existingClassNames.add(className);
existingRecordClassNames.add(className + "Record");
im.put("className", className);
im.put("classFileName", convertUsingFileNamingConvention(className));
}

if (this.getSagasAndRecords()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type {{className}},
{{className}}FromJSON,
{{className}}ToJSON,
} from '../models/{{className}}{{importFileExtension}}';
} from '../models/{{classFileName}}{{importFileExtension}}';
{{/imports}}
{{/withoutRuntimeChecks}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { Action } from "redux-ts-simple";
{{#imports}}
import {
{{className}},
} from '../models/{{className}}{{importFileExtension}}';
} from '../models/{{classFileName}}{{importFileExtension}}';
import {
{{className}}Record,
{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}RecordUtils,
} from '../models/{{className}}Record{{importFileExtension}}';
} from '../models/{{classFileName}}Record{{importFileExtension}}';
{{/imports}}
{{#passthroughImports}}
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,18 @@ public void testGeneratedFilenamesInKebabCase() throws IOException {

Map<String, Object> properties = new HashMap<>();
properties.put("fileNaming", TypeScriptFetchClientCodegen.KEBAB_CASE);
properties.put(TypeScriptFetchClientCodegen.WITHOUT_RUNTIME_CHECKS, false);

File output = generate(properties);

Path pet = Paths.get(output + "/models/pet.ts");
TestUtils.assertFileExists(pet);
TestUtils.assertFileContains(pet, "} from './pet-category';");
TestUtils.assertFileExists(Paths.get(output + "/models/pet-category.ts"));
TestUtils.assertFileExists(Paths.get(output + "/apis/pet-controller-api.ts"));
Path petApi = Paths.get(output + "/apis/pet-controller-api.ts");
TestUtils.assertFileExists(petApi);
TestUtils.assertFileContains(petApi, "} from '../models/pet';");
TestUtils.assertFileNotContains(petApi, "} from '../models/Pet';");
}

@Test(description = "Verify names of files generated in kebab-case and imports with additional model prefix")
Expand All @@ -310,14 +314,18 @@ public void testGeneratedFilenamesInKebabCaseWithAdditionalModelPrefix() throws
Map<String, Object> properties = new HashMap<>();
properties.put("fileNaming", TypeScriptFetchClientCodegen.KEBAB_CASE);
properties.put(CodegenConstants.MODEL_NAME_PREFIX, "SomePrefix");
properties.put(TypeScriptFetchClientCodegen.WITHOUT_RUNTIME_CHECKS, false);

File output = generate(properties);

Path pet = Paths.get(output + "/models/some-prefix-pet.ts");
TestUtils.assertFileExists(pet);
TestUtils.assertFileContains(pet, "} from './some-prefix-pet-category';");
TestUtils.assertFileExists(Paths.get(output + "/models/some-prefix-pet-category.ts"));
TestUtils.assertFileExists(Paths.get(output + "/apis/pet-controller-api.ts"));
Path petApi = Paths.get(output + "/apis/pet-controller-api.ts");
TestUtils.assertFileExists(petApi);
TestUtils.assertFileContains(petApi, "} from '../models/some-prefix-pet';");
TestUtils.assertFileNotContains(petApi, "} from '../models/SomePrefixPet';");
}

@Test(description = "Verify names of files generated in camelCase and imports")
Expand Down
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,118 @@
apis/another-fake-api.ts
apis/default-api.ts
apis/fake-api.ts
apis/fake-classname-tags123-api.ts
apis/index.ts
apis/pet-api.ts
apis/store-api.ts
apis/user-api.ts
docs/AdditionalPropertiesClass.md
docs/AllOfWithSingleRef.md
docs/Animal.md
docs/AnotherFakeApi.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
docs/Capitalization.md
docs/Cat.md
docs/Category.md
docs/ChildWithNullable.md
docs/ClassModel.md
docs/Client.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
docs/EnumArrays.md
docs/EnumClass.md
docs/EnumTest.md
docs/FakeApi.md
docs/FakeBigDecimalMap200Response.md
docs/FakeClassnameTags123Api.md
docs/FileSchemaTestClass.md
docs/Foo.md
docs/FooGetDefaultResponse.md
docs/FormatTest.md
docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md
docs/List.md
docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/ModelApiResponse.md
docs/ModelFile.md
docs/Name.md
docs/NullableClass.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
docs/Order.md
docs/OuterComposite.md
docs/OuterEnum.md
docs/OuterEnumDefaultValue.md
docs/OuterEnumInteger.md
docs/OuterEnumIntegerDefaultValue.md
docs/OuterObjectWithEnumProperty.md
docs/ParentWithNullable.md
docs/Pet.md
docs/PetApi.md
docs/ReadOnlyFirst.md
docs/Return.md
docs/SingleRefType.md
docs/SpecialModelName.md
docs/StoreApi.md
docs/Tag.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/User.md
docs/UserApi.md
index.ts
models/additional-properties-class.ts
models/all-of-with-single-ref.ts
models/animal.ts
models/array-of-array-of-number-only.ts
models/array-of-number-only.ts
models/array-test.ts
models/capitalization.ts
models/cat.ts
models/category.ts
models/child-with-nullable.ts
models/class-model.ts
models/client.ts
models/deprecated-object.ts
models/dog.ts
models/enum-arrays.ts
models/enum-class.ts
models/enum-test.ts
models/fake-big-decimal-map200-response.ts
models/file-schema-test-class.ts
models/foo-get-default-response.ts
models/foo.ts
models/format-test.ts
models/has-only-read-only.ts
models/health-check-result.ts
models/index.ts
models/list.ts
models/map-test.ts
models/mixed-properties-and-additional-properties-class.ts
models/model-api-response.ts
models/model-file.ts
models/model200-response.ts
models/name.ts
models/nullable-class.ts
models/number-only.ts
models/object-with-deprecated-fields.ts
models/order.ts
models/outer-composite.ts
models/outer-enum-default-value.ts
models/outer-enum-integer-default-value.ts
models/outer-enum-integer.ts
models/outer-enum.ts
models/outer-object-with-enum-property.ts
models/parent-with-nullable.ts
models/pet.ts
models/read-only-first.ts
models/return.ts
models/single-ref-type.ts
models/special-model-name.ts
models/tag.ts
models/test-inline-freeform-additional-properties-request.ts
models/user.ts
runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.24.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.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 Client,
ClientFromJSON,
ClientToJSON,
} from '../models/client';

export interface 123testSpecialTagsRequest {
client: Client;
}

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

/**
* Creates request options for _123testSpecialTags without sending the request
*/
async _123testSpecialTagsRequestOpts(requestParameters: 123testSpecialTagsRequest): Promise<runtime.RequestOpts> {
if (requestParameters['client'] == null) {
throw new runtime.RequiredError(
'client',
'Required parameter "client" was null or undefined when calling _123testSpecialTags().'
);
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/another-fake/dummy`;

return {
path: urlPath,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: ClientToJSON(requestParameters['client']),
};
}

/**
* To test special tags and operation ID starting with number
* To test special tags
*/
async _123testSpecialTagsRaw(requestParameters: 123testSpecialTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Client>> {
const requestOptions = await this._123testSpecialTagsRequestOpts(requestParameters);
const response = await this.request(requestOptions, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue));
}

/**
* To test special tags and operation ID starting with number
* To test special tags
*/
async _123testSpecialTags(requestParameters: 123testSpecialTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Client> {
const response = await this._123testSpecialTagsRaw(requestParameters, initOverrides);
return await response.value();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.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 FooGetDefaultResponse,
FooGetDefaultResponseFromJSON,
FooGetDefaultResponseToJSON,
} from '../models/foo-get-default-response';

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

/**
* Creates request options for fooGet without sending the request
*/
async fooGetRequestOpts(): Promise<runtime.RequestOpts> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/foo`;

return {
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
};
}

/**
*/
async fooGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FooGetDefaultResponse>> {
const requestOptions = await this.fooGetRequestOpts();
const response = await this.request(requestOptions, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => FooGetDefaultResponseFromJSON(jsonValue));
}

/**
*/
async fooGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FooGetDefaultResponse> {
const response = await this.fooGetRaw(initOverrides);
return await response.value();
}

}
Loading
Loading