-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<mat-toolbar color="primary"> | ||
<div class="container"> | ||
<button mat-icon-button (click)="onBack()"> | ||
<mat-icon>arrow_back</mat-icon> | ||
</button> | ||
|
||
<span class="title">Mage Swagger API</span> | ||
</div> | ||
</mat-toolbar> | ||
|
||
<div class="swagger-container"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.title { | ||
margin-left: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SwaggerComponent } from './swagger.component'; | ||
|
||
describe('SwaggerComponent', () => { | ||
let component: SwaggerComponent; | ||
let fixture: ComponentFixture<SwaggerComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [SwaggerComponent] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SwaggerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AfterViewInit, Component, ElementRef } from '@angular/core'; | ||
import { LocalStorageService } from '../http/local-storage.service'; | ||
import SwaggerUI from 'swagger-ui'; | ||
import { Router } from '@angular/router'; | ||
|
||
const DisableAuthorizePlugin = function () { | ||
return { | ||
wrapComponents: { | ||
AuthorizeBtnContainer: () => () => null, | ||
ServersContainer: () => () => null, | ||
authorizeOperationBtn: () => () => null | ||
} | ||
}; | ||
}; | ||
|
||
@Component({ | ||
selector: 'swagger', | ||
templateUrl: './swagger.component.html', | ||
styleUrls: ['./swagger.component.scss'] | ||
}) | ||
export class SwaggerComponent implements AfterViewInit { | ||
|
||
constructor( | ||
private el: ElementRef, | ||
private router: Router, | ||
private localStorageService: LocalStorageService | ||
) { | ||
} | ||
|
||
ngAfterViewInit() { | ||
SwaggerUI({ | ||
url: '/api/docs/openapi.yaml', | ||
domNode: this.el.nativeElement.querySelector('.swagger-container'), | ||
deepLinking: false, | ||
plugins: [DisableAuthorizePlugin], | ||
requestInterceptor: (request) => { | ||
request.headers['Authorization'] = `Bearer ${this.localStorageService.getToken()}` | ||
return request | ||
}, | ||
}); | ||
} | ||
|
||
onBack() : void { | ||
this.router.navigate(['about']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { SwaggerComponent } from "./swagger.component"; | ||
import { RouterModule, Routes } from "@angular/router"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
import { CommonModule } from "@angular/common"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { MatToolbarModule } from "@angular/material/toolbar"; | ||
|
||
const routes: Routes = [{ | ||
path: '', | ||
component: SwaggerComponent | ||
}]; | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [], | ||
exports: [ | ||
CommonModule, | ||
MatButtonModule, | ||
MatIconModule, | ||
MatToolbarModule | ||
] | ||
}) | ||
class AngularModule { } | ||
|
||
@NgModule({ | ||
declarations: [ | ||
SwaggerComponent | ||
], | ||
imports: [ | ||
AngularModule, | ||
RouterModule.forChild(routes) | ||
], | ||
exports: [ RouterModule ] | ||
}) | ||
export class SwaggerModule { | ||
} |