Skip to content

Commit

Permalink
fixup!: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Jul 30, 2019
1 parent 0a8df75 commit 66ffa8f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
9 changes: 2 additions & 7 deletions packages/openapi-v3/_spike-request-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,9 @@ class MyController2 {
@put('/Product')
update(
@requestBody2(
{
description: 'Update a product',
required: true,
},
{description: 'Update a product', required: true},
Product,
{
partial: true,
},
{partial: true},
)
product: Partial<Product>,
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,9 @@ describe('spike - requestBody decorator', () => {
@post('/Product')
create(
@requestBody2(
{
description: 'Create a product',
required: true,
},
{description: 'Create a product', required: true},
Product,
{
exclude: ['id'],
},
{exclude: ['id']},
)
product: Exclude<Product, ['id']>,
) {}
Expand Down Expand Up @@ -114,14 +109,9 @@ describe('spike - requestBody decorator', () => {
@put('/Product')
update(
@requestBody2(
{
description: 'Update a product',
required: true,
},
{description: 'Update a product', required: true},
Product,
{
partial: true,
},
{partial: true},
)
product: Partial<Product>,
) {}
Expand Down
14 changes: 4 additions & 10 deletions packages/openapi-v3/src/decorators/request-body.spike.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import {MetadataInspector, ParameterDecoratorFactory} from '@loopback/context';
import {JsonSchemaOptions} from '@loopback/repository-json-schema';
import * as _ from 'lodash';
import {inspect} from 'util';
import {
TS_TYPE_KEY,
isComplexType,
getModelSchemaRef,
} from '../controller-spec';
import {isComplexType, getModelSchemaRef} from '../controller-spec';
import {resolveSchema} from '../generate-schema';
import {OAI3Keys} from '../keys';
import {RequestBodyObject, REQUEST_BODY_INDEX, SchemaObject} from '../types';
Expand Down Expand Up @@ -103,11 +99,9 @@ function _requestBody2<T extends object>(

const paramType = paramTypes[index];

// preserve backward compatibility
if (modelCtor)
schemaOptions = Object.assign({}, schemaOptions, {
[TS_TYPE_KEY]: modelCtor,
});
// // preserve backward compatibility
// if (modelCtor)
// schemaOptions = Object.assign({}, schemaOptions);

// Assumption: the paramType is always the type to be configured
let schema: SchemaObject;
Expand Down

0 comments on commit 66ffa8f

Please sign in to comment.