Skip to content

Commit

Permalink
Merge pull request #908 from hey-api/fix/types-tree-services
Browse files Browse the repository at this point in the history
fix: do not generate types tree by default if services are enabled as it is unused
  • Loading branch information
mrlubos authored Aug 12, 2024
2 parents 5425177 + 225b640 commit 5161e1a
Show file tree
Hide file tree
Showing 38 changed files with 16 additions and 7,589 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-suits-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

fix: do not generate types tree by default if services are enabled as it is unused
9 changes: 6 additions & 3 deletions packages/openapi-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ const getServices = (userConfig: ClientConfig): Config['services'] => {
return services;
};

const getTypes = (userConfig: ClientConfig): Config['types'] => {
const getTypes = (
userConfig: ClientConfig,
services: Config['services'],
): Config['types'] => {
let types: Config['types'] = {
dates: false,
enums: false,
export: true,
name: 'preserve',
tree: true,
tree: !services.export,
};
if (typeof userConfig.types === 'boolean') {
types.export = userConfig.types;
Expand Down Expand Up @@ -273,7 +276,7 @@ const initConfigs = async (userConfig: UserConfig): Promise<Config[]> => {
const plugins = getPlugins(userConfig);
const schemas = getSchemas(userConfig);
const services = getServices(userConfig);
const types = getTypes(userConfig);
const types = getTypes(userConfig, services);

output.path = path.resolve(process.cwd(), output.path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,273 +755,4 @@ export type NonAsciiæøåÆøÅöôêÊ字符串Data = {
nonAsciiParamæøåÆøÅöôêÊ: number;
};

export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiStringæøåÆØÅöôêÊ字符串;

export type $OpenApiTs = {
'/api/v{api-version}/body': {
post: {
req: PostApiBodyData;
res: {
/**
* OK
*/
200: response_PostActivityResponse;
/**
* Bad Request
*/
400: failure_Failure;
/**
* Internal Server Error
*/
500: failure_Failure;
};
};
};
'/api/v{api-version}/descriptions/': {
post: {
req: CallWithDescriptionsData;
};
};
'/api/v{api-version}/parameters/{parameterPath}': {
post: {
req: CallWithParametersData;
};
};
'/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': {
post: {
req: CallWithWeirdParameterNamesData;
};
};
'/api/v{api-version}/defaults': {
get: {
req: CallWithDefaultParametersData;
};
post: {
req: CallWithDefaultOptionalParametersData;
};
put: {
req: CallToTestOrderOfParamsData;
};
};
'/api/v{api-version}/no-content': {
get: {
res: {
/**
* Success
*/
204: void;
};
};
};
'/api/v{api-version}/multiple-tags/response-and-no-content': {
get: {
res: {
/**
* Response is a simple number
*/
200: unknown;
/**
* Success
*/
204: void;
};
};
};
'/api/v{api-version}/response': {
get: {
res: {
/**
* Message for default response
*/
default: ModelWithString;
};
};
post: {
res: {
/**
* Message for 201 response
*/
201: ModelWithString;
/**
* Message for 202 response
*/
202: ModelWithString;
/**
* Message for 500 error
*/
500: ModelWithStringError;
/**
* Message for 501 error
*/
501: ModelWithStringError;
/**
* Message for 502 error
*/
502: ModelWithStringError;
/**
* Message for default response
*/
default: ModelWithString;
};
};
put: {
res: {
/**
* Message for 200 response
*/
200: {
readonly '@namespace.string'?: string;
readonly '@namespace.integer'?: number;
readonly value?: Array<ModelWithString>;
};
/**
* Message for 201 response
*/
201: ModelThatExtends;
/**
* Message for 202 response
*/
202: ModelThatExtendsExtends;
/**
* Message for 500 error
*/
500: ModelWithStringError;
/**
* Message for 501 error
*/
501: ModelWithStringError;
/**
* Message for 502 error
*/
502: ModelWithStringError;
/**
* Message for default response
*/
default: ModelWithString;
};
};
};
'/api/v{api-version}/multiple-tags/a': {
get: {
res: {
/**
* Success
*/
204: void;
};
};
};
'/api/v{api-version}/multiple-tags/b': {
get: {
res: {
/**
* Success
*/
204: void;
};
};
};
'/api/v{api-version}/collectionFormat': {
get: {
req: CollectionFormatData;
};
};
'/api/v{api-version}/types': {
get: {
req: TypesData;
res: {
/**
* Response is a simple number
*/
200: number;
/**
* Response is a simple string
*/
201: string;
/**
* Response is a simple boolean
*/
202: boolean;
/**
* Response is a simple object
*/
203: unknown;
};
};
};
'/api/v{api-version}/complex': {
get: {
req: ComplexTypesData;
res: {
/**
* Successful response
*/
200: Array<ModelWithString>;
/**
* 400 server error
*/
400: unknown;
/**
* 500 server error
*/
500: unknown;
};
};
};
'/api/v{api-version}/header': {
post: {
res: {
/**
* Successful response
*/
200: string;
/**
* 400 server error
*/
400: unknown;
/**
* 500 server error
*/
500: unknown;
};
};
};
'/api/v{api-version}/error': {
post: {
req: TestErrorCodeData;
res: {
/**
* Custom message: Successful response
*/
200: unknown;
/**
* Custom message: Internal Server Error
*/
500: unknown;
/**
* Custom message: Not Implemented
*/
501: unknown;
/**
* Custom message: Bad Gateway
*/
502: unknown;
/**
* Custom message: Service Unavailable
*/
503: unknown;
};
};
};
'/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': {
post: {
req: NonAsciiæøåÆøÅöôêÊ字符串Data;
res: {
/**
* Successful response
*/
200: NonAsciiStringæøåÆØÅöôêÊ字符串;
};
};
};
};
export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiStringæøåÆØÅöôêÊ字符串;
Loading

0 comments on commit 5161e1a

Please sign in to comment.