diff --git a/config/swagger-generator.php b/config/swagger-generator.php index 9c40b23..b0775fb 100644 --- a/config/swagger-generator.php +++ b/config/swagger-generator.php @@ -77,6 +77,12 @@ 'ignoredAnnotationNames' => ['mixin'], /* |--------------------------------------------------------- + | Generate objects inside 'components.schemas' instead of 'components.x-objects' + |--------------------------------------------------------- + */ + 'generateObjectsAsSchemas' => false, + /* + |--------------------------------------------------------- | List of classes to additionally generate definitions |--------------------------------------------------------- | diff --git a/src/Describer/CollectsClassReferences.php b/src/Describer/CollectsClassReferences.php index fe7a03c..fac3043 100644 --- a/src/Describer/CollectsClassReferences.php +++ b/src/Describer/CollectsClassReferences.php @@ -122,7 +122,8 @@ private static function getCollectedClassReferenceName(string $className, array return static::$collectedClassReferencesKeys[$classNameWithAttributes]; } $classNameSafe = str_replace(['\\', '.'], '_', $classNameWithAttributes); - $keys = ['components', RoutesParser::COMPONENT_OBJECTS, $classNameSafe]; + $componentsKey = config('swagger-generator.generateObjectsAsSchemas', false) ? RoutesParser::COMPONENT_SCHEMAS : RoutesParser::COMPONENT_OBJECTS; + $keys = ['components', $componentsKey, $classNameSafe]; return static::$collectedClassReferencesKeys[$classNameWithAttributes] = '#/' . implode('/', $keys); } diff --git a/src/RoutesParser.php b/src/RoutesParser.php index 9c51336..7779094 100644 --- a/src/RoutesParser.php +++ b/src/RoutesParser.php @@ -34,6 +34,7 @@ class RoutesParser const COMPONENT_REQUESTS = 'requestBodies'; const COMPONENT_PARAMETER = 'parameters'; const COMPONENT_OBJECTS = 'x-objects'; + const COMPONENT_SCHEMAS = 'schemas'; const PROBLEM_NO_RESPONSE = 'no_response'; const PROBLEM_ROUTE_CLOSURE = 'route_closure';