splitted oas.yaml
This commit is contained in:
		
							
								
								
									
										18
									
								
								src/index.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/index.ts
									
									
									
									
									
								
							@@ -2,7 +2,7 @@ import cfenv from 'cfenv';
 | 
			
		||||
import express from 'express';
 | 
			
		||||
import mongoose from 'mongoose';
 | 
			
		||||
import swagger from 'swagger-ui-express';
 | 
			
		||||
import yaml from 'yamljs';
 | 
			
		||||
import jsonRefParser, {JSONSchema} from '@apidevtools/json-schema-ref-parser';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// tell if server is running in debug or production environment
 | 
			
		||||
@@ -44,14 +44,14 @@ const port = process.env.PORT || 3000;
 | 
			
		||||
app.use('/', require('./routes/root'));
 | 
			
		||||
 | 
			
		||||
// Swagger UI
 | 
			
		||||
app.use('/api', swagger.serve, swagger.setup(
 | 
			
		||||
  yaml.load('./oas.yaml'),
 | 
			
		||||
  {
 | 
			
		||||
    defaultModelsExpandDepth: -1,
 | 
			
		||||
    customCss: '.swagger-ui .topbar { display: none }'
 | 
			
		||||
  }
 | 
			
		||||
  )
 | 
			
		||||
);
 | 
			
		||||
let oasDoc: JSONSchema = {};
 | 
			
		||||
jsonRefParser.bundle('oas/oas.yaml', (err, doc) => {
 | 
			
		||||
  if(err) throw err;
 | 
			
		||||
  oasDoc = doc;
 | 
			
		||||
  oasDoc.paths = oasDoc.paths.allOf.reduce((s, e) => Object.assign(s, e));
 | 
			
		||||
  swagger.setup(oasDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'});
 | 
			
		||||
});
 | 
			
		||||
app.use('/api', swagger.serve, swagger.setup(oasDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'}));
 | 
			
		||||
 | 
			
		||||
// hook up server to port
 | 
			
		||||
app.listen(port, () => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user