Skip to content

Commit 2524d26

Browse files
committed
update security samples
1 parent 5d61e7b commit 2524d26

File tree

10 files changed

+51
-34
lines changed

10 files changed

+51
-34
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.0-SNAPSHOT
1+
2.4.44

samples/client/petstore-security-test/typescript-angular/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Building
44

5-
To build an compile the typescript sources to javascript use:
5+
To install the required dependencies and to build the typescript sources run:
66
```
77
npm install
88
npm run build
@@ -14,15 +14,15 @@ First build the package than run ```npm publish```
1414

1515
### consuming
1616

17-
navigate to the folder of your consuming project and run one of next commando's.
17+
Navigate to the folder of your consuming project and run one of next commands.
1818

1919
_published:_
2020

2121
```
2222
npm install @ --save
2323
```
2424

25-
_unPublished (not recommended):_
25+
_without publishing (not recommended):_
2626

2727
```
2828
npm install PATH_TO_GENERATED_PACKAGE --save
@@ -37,9 +37,16 @@ npm link
3737

3838
In your project:
3939
```
40-
npm link @
40+
npm link
4141
```
4242

43+
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
44+
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
45+
Published packages are not effected by this issue.
46+
47+
48+
#### General usage
49+
4350
In your Angular project:
4451

4552

samples/client/petstore-security-test/typescript-angular/api.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ApiModule {
1717
return {
1818
ngModule: ApiModule,
1919
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
20-
}
20+
};
2121
}
2222

2323
constructor( @Optional() @SkipSelf() parentModule: ApiModule,

samples/client/petstore-security-test/typescript-angular/api/fake.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class FakeService {
4646
*/
4747
private canConsumeForm(consumes: string[]): boolean {
4848
const form = 'multipart/form-data';
49-
for (let consume of consumes) {
49+
for (const consume of consumes) {
5050
if (form === consume) {
5151
return true;
5252
}
@@ -67,27 +67,28 @@ export class FakeService {
6767
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
6868
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
6969

70+
7071
let headers = this.defaultHeaders;
7172

7273
// to determine the Accept header
7374
let httpHeaderAccepts: string[] = [
7475
'application/json',
7576
'*_/ =end -- '
7677
];
77-
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
78+
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
7879
if (httpHeaderAcceptSelected != undefined) {
79-
headers = headers.set("Accept", httpHeaderAcceptSelected);
80+
headers = headers.set('Accept', httpHeaderAcceptSelected);
8081
}
8182

8283
// to determine the Content-Type header
83-
let consumes: string[] = [
84+
const consumes: string[] = [
8485
'application/json',
8586
'*_/ =end -- '
8687
];
8788

8889
const canConsumeForm = this.canConsumeForm(consumes);
8990

90-
let formParams: { append(param: string, value: any): void; };
91+
let formParams: { append(param: string, value: any): void | HttpParams; };
9192
let useForm = false;
9293
let convertFormParamsToString = false;
9394
if (useForm) {

samples/client/petstore-security-test/typescript-angular/configuration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class Configuration {
2828
* Select the correct content-type to use for a request.
2929
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
3030
* If no content type is found return the first found type if the contentTypes is not empty
31-
* @param {string[]} contentTypes - the array of content types that are available for selection
32-
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
31+
* @param contentTypes - the array of content types that are available for selection
32+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
3333
*/
3434
public selectHeaderContentType (contentTypes: string[]): string | undefined {
3535
if (contentTypes.length == 0) {
@@ -47,8 +47,8 @@ export class Configuration {
4747
* Select the correct accept content-type to use for a request.
4848
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
4949
* If no content type is found return the first found type if the contentTypes is not empty
50-
* @param {string[]} accepts - the array of content types that are available for selection.
51-
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
50+
* @param accepts - the array of content types that are available for selection.
51+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
5252
*/
5353
public selectHeaderAccept(accepts: string[]): string | undefined {
5454
if (accepts.length == 0) {
@@ -69,8 +69,8 @@ export class Configuration {
6969
* application/json; charset=UTF8
7070
* APPLICATION/JSON
7171
* application/vnd.company+json
72-
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
73-
* @return {boolean} True if the given MIME is JSON, false otherwise.
72+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
73+
* @return True if the given MIME is JSON, false otherwise.
7474
*/
7575
public isJsonMime(mime: string): boolean {
7676
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.0-SNAPSHOT
1+
2.4.44

samples/client/petstore-security-test/typescript-angular2/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Building
44

5-
To build an compile the typescript sources to javascript use:
5+
To install the required dependencies and to build the typescript sources run:
66
```
77
npm install
88
npm run build
@@ -14,15 +14,15 @@ First build the package than run ```npm publish```
1414

1515
### consuming
1616

17-
navigate to the folder of your consuming project and run one of next commando's.
17+
Navigate to the folder of your consuming project and run one of next commands.
1818

1919
_published:_
2020

2121
```
2222
npm install @ --save
2323
```
2424

25-
_unPublished (not recommended):_
25+
_without publishing (not recommended):_
2626

2727
```
2828
npm install PATH_TO_GENERATED_PACKAGE --save
@@ -37,9 +37,16 @@ npm link
3737

3838
In your project:
3939
```
40-
npm link @
40+
npm link
4141
```
4242

43+
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
44+
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
45+
Published packages are not effected by this issue.
46+
47+
48+
#### General usage
49+
4350
In your Angular project:
4451

4552

samples/client/petstore-security-test/typescript-angular2/api.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ApiModule {
1717
return {
1818
ngModule: ApiModule,
1919
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
20-
}
20+
};
2121
}
2222

2323
constructor( @Optional() @SkipSelf() parentModule: ApiModule,

samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class FakeService {
4646
*/
4747
private canConsumeForm(consumes: string[]): boolean {
4848
const form = 'multipart/form-data';
49-
for (let consume of consumes) {
49+
for (const consume of consumes) {
5050
if (form === consume) {
5151
return true;
5252
}
@@ -67,27 +67,28 @@ export class FakeService {
6767
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
6868
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
6969

70+
7071
let headers = this.defaultHeaders;
7172

7273
// to determine the Accept header
7374
let httpHeaderAccepts: string[] = [
7475
'application/json',
7576
'*_/ =end -- '
7677
];
77-
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
78+
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
7879
if (httpHeaderAcceptSelected != undefined) {
79-
headers = headers.set("Accept", httpHeaderAcceptSelected);
80+
headers = headers.set('Accept', httpHeaderAcceptSelected);
8081
}
8182

8283
// to determine the Content-Type header
83-
let consumes: string[] = [
84+
const consumes: string[] = [
8485
'application/json',
8586
'*_/ =end -- '
8687
];
8788

8889
const canConsumeForm = this.canConsumeForm(consumes);
8990

90-
let formParams: { append(param: string, value: any): void; };
91+
let formParams: { append(param: string, value: any): void | HttpParams; };
9192
let useForm = false;
9293
let convertFormParamsToString = false;
9394
if (useForm) {
@@ -103,6 +104,7 @@ export class FakeService {
103104
return this.httpClient.put<any>(`${this.basePath}/fake`,
104105
convertFormParamsToString ? formParams.toString() : formParams,
105106
{
107+
// not text :(
106108
withCredentials: this.configuration.withCredentials,
107109
headers: headers,
108110
observe: observe,

samples/client/petstore-security-test/typescript-angular2/configuration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class Configuration {
2828
* Select the correct content-type to use for a request.
2929
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
3030
* If no content type is found return the first found type if the contentTypes is not empty
31-
* @param {string[]} contentTypes - the array of content types that are available for selection
32-
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
31+
* @param contentTypes - the array of content types that are available for selection
32+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
3333
*/
3434
public selectHeaderContentType (contentTypes: string[]): string | undefined {
3535
if (contentTypes.length == 0) {
@@ -47,8 +47,8 @@ export class Configuration {
4747
* Select the correct accept content-type to use for a request.
4848
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
4949
* If no content type is found return the first found type if the contentTypes is not empty
50-
* @param {string[]} accepts - the array of content types that are available for selection.
51-
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
50+
* @param accepts - the array of content types that are available for selection.
51+
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
5252
*/
5353
public selectHeaderAccept(accepts: string[]): string | undefined {
5454
if (accepts.length == 0) {
@@ -69,8 +69,8 @@ export class Configuration {
6969
* application/json; charset=UTF8
7070
* APPLICATION/JSON
7171
* application/vnd.company+json
72-
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
73-
* @return {boolean} True if the given MIME is JSON, false otherwise.
72+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
73+
* @return True if the given MIME is JSON, false otherwise.
7474
*/
7575
public isJsonMime(mime: string): boolean {
7676
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');

0 commit comments

Comments
 (0)