Skip to content

Commit 9f99004

Browse files
committed
fix(request): allow customName for http request
1 parent 657527e commit 9f99004

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

packages/serverless-openapi/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Serverless from 'serverless';
22
import { CustomProperties, customProperties } from './lib/custom.properties';
33
import { writeFileSync } from 'fs';
4-
import { functioneventProperties } from './lib/functionEvent.properties';
4+
import { functionEventProperties } from './lib/functionEvent.properties';
55
import { dump } from 'js-yaml';
66
import { CommandsDefinition } from './lib/comand.types';
77
import { Generator } from './lib/generator';
@@ -49,7 +49,7 @@ export class ServerlessPlugin {
4949
serverless.configSchemaHandler.defineFunctionEventProperties(
5050
'aws',
5151
'http',
52-
functioneventProperties
52+
functionEventProperties
5353
);
5454

5555
this.hooks = {

packages/serverless-openapi/src/lib/functionEvent.properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { JSONSchema7 } from 'json-schema';
22

3-
export const functioneventProperties = {
3+
export const functionEventProperties = {
44
properties: {
55
tags: {
66
type: 'array',

packages/serverless-openapi/src/lib/generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,18 @@ export class Generator {
202202

203203
const schemaJSON = requestSchemas['application/json'];
204204
request.description = schemaJSON.description;
205+
const name = schemaJSON.customName ?? schemaJSON.name;
205206

206207
if (schemaJSON.schema) {
207208
request['content'] = {
208209
'application/json': {
209210
schema: {
210-
$ref: '#/components/schemas/' + schemaJSON.name,
211+
$ref: '#/components/schemas/' + name,
211212
},
212213
},
213214
};
214215
delete schemaJSON.schema['$schema'];
215-
openApi.components.schemas[schemaJSON.name] = schemaJSON.schema as any;
216+
openApi.components.schemas[name] = schemaJSON.schema as any;
216217
}
217218
return request;
218219
}

packages/serverless-openapi/src/lib/response.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { JSONSchema7 } from 'json-schema';
22

33
export interface Schema {
44
schema?: JSONSchema7;
5-
name: string;
5+
customName?: string;
6+
name?: string;
67
description?: string;
78
}

0 commit comments

Comments
 (0)