File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " serverless-openapi-documenter" ,
3- "version" : " 0.1.5 " ,
3+ "version" : " 0.1.6 " ,
44 "description" : " Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config" ,
55 "main" : " index.js" ,
66 "keywords" : [
4646 },
4747 "repository" : {
4848 "type" : " git" ,
49- "url" : " https://github.com/JaredCE/serverless-openapi-documenter.git"
49+ "url" : " git+ https://github.com/JaredCE/serverless-openapi-documenter.git"
5050 },
5151 "bugs" : {
5252 "url" : " https://github.com/JaredCE/serverless-openapi-documenter/issues"
Original file line number Diff line number Diff line change @@ -696,6 +696,10 @@ class DefinitionGenerator {
696696 return obj ;
697697 }
698698
699+ schemaExistsInSchemaModels ( model , currentContentType ) {
700+ return currentContentType === model . name || currentContentType === model ?. apiGatewayKey
701+ }
702+
699703 async createMediaTypeObject ( models , type ) {
700704 const mediaTypeObj = { } ;
701705 for ( const mediaTypeDocumentation of this . schemaHandler . models ) {
@@ -706,9 +710,11 @@ class DefinitionGenerator {
706710 }
707711
708712 for ( const modelContentType in models ) {
709- let contentKey
713+ let contentKey ;
714+ let modelName = mediaTypeDocumentation . name ;
710715
711- if ( models [ modelContentType ] === mediaTypeDocumentation . name ) {
716+ if ( this . schemaExistsInSchemaModels ( mediaTypeDocumentation , models [ modelContentType ] ) ) {
717+ if ( models [ modelContentType ] === mediaTypeDocumentation ?. apiGatewayKey ) { modelName = mediaTypeDocumentation . apiGatewayKey ; }
712718 contentKey = modelContentType ;
713719 }
714720
@@ -742,7 +748,7 @@ class DefinitionGenerator {
742748 }
743749
744750 const schemaRef = await this . schemaHandler
745- . createSchema ( mediaTypeDocumentation . name )
751+ . createSchema ( modelName )
746752 . catch ( ( err ) => {
747753 throw err ;
748754 } ) ;
Original file line number Diff line number Diff line change @@ -75,7 +75,9 @@ class SchemaHandler {
7575 const standardisedGatewayModels =
7676 Object . keys ( this . apiGatewayModels ) . flatMap ( ( key ) => {
7777 const gatewayModel = this . apiGatewayModels [ key ] ;
78- return standardModel ( gatewayModel ) ;
78+ const model = standardModel ( gatewayModel ) ;
79+ model . apiGatewayKey = key ;
80+ return model ;
7981 } ) || [ ] ;
8082
8183 this . models = standardisedModels . concat (
@@ -86,7 +88,8 @@ class SchemaHandler {
8688
8789 async addModelsToOpenAPI ( ) {
8890 for ( const model of this . models ) {
89- const modelName = model . name ;
91+ const modelName = model ?. apiGatewayKey || model . name ;
92+
9093 const schemas = [ ]
9194 if ( model . schema ) {
9295 // const modelSchema = model.schema;
You can’t perform that action at this time.
0 commit comments