Skip to content

Commit 212942e

Browse files
Merge branch 'develop' into main
2 parents 068c5d7 + c575ed1 commit 212942e

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
10+
## [2.1.1] - 2021-01-03
11+
12+
### Added
13+
- Now `-v` is available as parameter as `--version` alias.
14+
15+
### Changed
16+
- Auto-generated types (parameters, request body, ... without explicit declaration) forced to to CapitalCase (UpperCamelCase).
17+
> Please check and update your code after generate the template.
18+
19+
### Fixed
20+
- "Native" types previously was generating a new model in parameters or other cases.
21+
922
## [2.1.0] - 2021-01-02
1023

1124
### Changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@protocolnebula/ts-openapi-generator",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Build API and models from Swagger/OpenAPI to use in any project type",
55
"main": "dist/main.js",
66
"types": "dist/main.d.ts",

src/services/arguments.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as yargs from 'yargs';
22

33
export const argumentsInstance = yargs
4+
.alias('version', 'v')
45
.usage('Usage: $0 [options]')
56
// .command('count', 'Count the lines in a file')
67
.example(

src/services/parsers/open-api-v3/parser-base.service.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { camel } from 'case';
1+
import { capital } from 'case';
22
import { OpenAPIV3 } from 'openapi-types';
33
import { ModelAttributessModel } from '../../../models/model-attributes.model';
44
import { ModelModel } from '../../../models/model.model';
@@ -95,7 +95,7 @@ export abstract class ParserBaseService {
9595
const parameter = new ModelAttributessModel(rawParameter.name);
9696
parameter.typeURI = this.parseSchema(
9797
rawParameter.schema,
98-
camel(`${defaultName} ${rawParameter.name}`),
98+
capital(`${defaultName} ${rawParameter.name}`, '', true),
9999
)?.typeURI;
100100
parameter.description = rawParameter.description;
101101
parameter.deprecated = rawParameter.deprecated;
@@ -125,17 +125,18 @@ export abstract class ParserBaseService {
125125
instance.typeURI = schema.$ref;
126126
return instance;
127127
} else if (this.isSchemaObject(schema)) {
128-
if (mediaType === 'text/html') {
129-
const instance = new ModelAttributessModel(null);
130-
instance.typeURI = schema.type;
131-
return instance;
132-
}
133128
if (schema.type === 'array') {
134129
const instance = this.parseSchema(schema.items, defaultName, mediaType);
135130
instance.isArray = true;
136131
return instance;
137132
}
138133

134+
if (mediaType === 'text/html' || schema?.type !== 'object') {
135+
const instance = new ModelAttributessModel(null);
136+
instance.typeURI = schema.type;
137+
return instance;
138+
}
139+
139140
const newModel = new ModelModel(defaultName);
140141
newModel.addAttributes(this.parseAttributes(schema));
141142
this.store.models.add(newModel);

src/utils/models.util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { camel } from 'case';
1+
import { capital } from 'case';
22
import { ApiModel } from '../models/api.model';
33
import { PhysycalFile } from '../models/entities';
44
import { Store } from '../stores/entities.store';
@@ -65,5 +65,5 @@ export function getApiDefaultModelName(
6565
api: ApiModel,
6666
modelFor: string = 'request',
6767
): string {
68-
return camel(`${api.verb.toLowerCase()} ${api.name} ${modelFor}`);
68+
return capital(`${api.verb.toLowerCase()} ${api.name} ${modelFor}`, '', true);
6969
}

0 commit comments

Comments
 (0)