nestjs-openapi 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1057,12 +1057,12 @@ const decoratorHandlers = {
1057
1057
  })
1058
1058
  ),
1059
1059
  ApiProperty: apiPropertyDecoratorHandler,
1060
- ApiPropertyOptional: apiPropertyDecoratorHandler
1060
+ ApiPropertyOptional: (state, decorator) => apiPropertyDecoratorHandler({ ...state, isOptional: true }, decorator)
1061
1061
  };
1062
- const INITIAL_PROPERTY_VALIDATION_INFO = {
1063
- isOptional: false,
1062
+ const createInitialPropertyValidationInfo = (property) => ({
1063
+ isOptional: property.hasQuestionToken(),
1064
1064
  constraints: {}
1065
- };
1065
+ });
1066
1066
  const applyDecorator = (state, decorator) => getDecoratorName(decorator).pipe(
1067
1067
  Option.flatMap((name) => Option.fromNullable(decoratorHandlers[name])),
1068
1068
  Option.match({
@@ -1072,7 +1072,7 @@ const applyDecorator = (state, decorator) => getDecoratorName(decorator).pipe(
1072
1072
  );
1073
1073
  const extractPropertyState = (property) => property.getDecorators().reduce(
1074
1074
  applyDecorator,
1075
- INITIAL_PROPERTY_VALIDATION_INFO
1075
+ createInitialPropertyValidationInfo(property)
1076
1076
  );
1077
1077
  const hasConstraints = (constraints) => Object.keys(constraints).length > 0;
1078
1078
  const extractPropertyConstraints = (property) => extractPropertyState(property).constraints;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-openapi",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Static code analysis tool to generate OpenAPI specifications from NestJS applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",