Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger to use Swashbuckle.SwaggerGen and Swashbuckle.SwaggerUi #492

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Asp2017.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="Swashbuckle.SwaggerGen" Version="6.0.0-beta902" />
<PackageReference Include="Swashbuckle.SwaggerUi" Version="6.0.0-beta902" />
</ItemGroup>
<ItemGroup>
<!-- Files not to show in IDE -->
Expand Down
2 changes: 1 addition & 1 deletion ClientApp/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="col-sm-3">
<nav-menu></nav-menu>
<app-nav-menu></app-nav-menu>
</div>
<div class="col-sm-9 body-content">
<router-outlet></router-outlet>
Expand Down
4 changes: 3 additions & 1 deletion ClientApp/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
$navbar-default-bg: #312312;
$navbar-default-bg: #312312;
$light-orange: #ff8c00;
$navbar-default-color: $light-orange;

/* Import Bootstrap & Fonts */
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
@import "~bootstrap-sass/assets/stylesheets/bootstrap";

/*@import '~bootstrap/dist/css/bootstrap.min.css';*/

@import "./css/browser.styles";


/* *** Overall APP Styling can go here ***
Expand Down
11 changes: 7 additions & 4 deletions ClientApp/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID } from '@angular/core';
import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID, Injector } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
import { Meta, Title, DOCUMENT, MetaDefinition } from '@angular/platform-browser';
import { Subscription } from 'rxjs/Subscription';
Expand All @@ -7,10 +7,10 @@ import { LinkService } from './shared/link.service';

// i18n support
import { TranslateService } from '@ngx-translate/core';
import { REQUEST } from './shared/constants/request';
import { REQUEST } from '@nguniversal/aspnetcore-engine';

@Component({
selector: 'app',
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None
Expand All @@ -23,6 +23,7 @@ export class AppComponent implements OnInit, OnDestroy {
private defaultPageTitle: string = 'My App';

private routerSub$: Subscription;
private request;

constructor(
private router: Router,
Expand All @@ -31,14 +32,16 @@ export class AppComponent implements OnInit, OnDestroy {
private meta: Meta,
private linkService: LinkService,
public translate: TranslateService,
@Inject(REQUEST) private request
private injector: Injector
) {
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en');

// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use('en');

this.request = this.injector.get(REQUEST);

console.log(`What's our REQUEST Object look like?`);
console.log(`The Request object only really exists on the Server, but on the Browser we can at least see Cookies`);
console.log(this.request);
Expand Down
15 changes: 6 additions & 9 deletions ClientApp/app/app.module.browser.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { NgModule } from '@angular/core';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { APP_BASE_HREF } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { ORIGIN_URL } from './shared/constants/baseurl.constants';
import { ORIGIN_URL, REQUEST } from '@nguniversal/aspnetcore-engine';
import { AppModuleShared } from './app.module';
import { AppComponent } from './app.component';
import { REQUEST } from './shared/constants/request';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';

import { BrowserTransferStateModule } from '@angular/platform-browser';
import { BrowserPrebootModule } from 'preboot/browser';

import '../../ClientApp/jquery.plugins/jquery.themepunch.plugins.min.js';
import '../../ClientApp/jquery.plugins/jquery.themepunch.revolution.min.js';

export function getOriginUrl() {
return window.location.origin;
}
Expand All @@ -23,12 +24,8 @@ export function getRequest() {
@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({
appId: 'my-app-id' // make sure this matches with your Server NgModule
}),
BrowserPrebootModule.replayEvents(),
BrowserAnimationsModule,
BrowserTransferStateModule,

// Our Common AppModule
AppModuleShared
Expand Down
25 changes: 10 additions & 15 deletions ClientApp/app/app.module.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,28 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { AppModuleShared } from './app.module';
import { AppComponent } from './app.component';
import { ServerTransferStateModule } from '../modules/transfer-state/server-transfer-state.module';
import { TransferState } from '../modules/transfer-state/transfer-state';
import { ServerTransferStateModule } from '@angular/platform-server';

import { ServerPrebootModule } from 'preboot/server';

@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({
appId: 'my-app-id' // make sure this matches with your Browser NgModule
}),
// Our Common AppModule
AppModuleShared,

ServerModule,
ServerPrebootModule.recordEvents({ appRoot: 'app' }),
ServerPrebootModule.recordEvents({ appRoot: 'app-root' }),
NoopAnimationsModule,

ServerTransferStateModule,

// Our Common AppModule
AppModuleShared
// HttpTransferCacheModule still needs fixes for 5.0
// Leave this commented out for now, as it breaks Server-renders
// Looking into fixes for this! - @MarkPieszak
// ServerTransferStateModule // <-- broken for the time-being with ASP.NET
]
})
export class AppModule {

constructor(private transferState: TransferState) { }
constructor() { }

// Gotcha (needs to be an arrow function)
ngOnBootstrap = () => {
this.transferState.inject();
}
}
40 changes: 27 additions & 13 deletions ClientApp/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { NgModule, Inject } from '@angular/core';
import { RouterModule, PreloadAllModules } from '@angular/router';
import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { HttpModule, Http } from '@angular/http';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
import { TransferHttpCacheModule } from '@nguniversal/common';
import { ReactiveFormsModule } from '@angular/forms';
import { FormlyModule } from '@ngx-formly/core';
import { FormlyBootstrapModule } from '@ngx-formly/bootstrap';

import { Ng2BootstrapModule } from 'ngx-bootstrap';

Expand All @@ -12,21 +18,20 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { AppComponent } from './app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { CircularJsonPipe } from './components/json-circ/json-circ.pipe';
import { CoverSlideModuleComponent } from './components/cover-slide-module/cover-slide-module.component';
import { HomeComponent } from './containers/home/home.component';
import { UsersComponent } from './containers/users/users.component';
import { UserDetailComponent } from './components/user-detail/user-detail.component';
import { CounterComponent } from './containers/counter/counter.component';
// import { ChatComponent } from './containers/chat/chat.component';
import { NotFoundComponent } from './containers/not-found/not-found.component';
import { NgxBootstrapComponent } from './containers/ngx-bootstrap-demo/ngx-bootstrap.component';

import { LinkService } from './shared/link.service';
import { UserService } from './shared/user.service';
// import { ConnectionResolver } from './shared/route.resolver';
import { ORIGIN_URL } from './shared/constants/baseurl.constants';
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine';

export function createTranslateLoader(http: Http, baseHref) {
export function createTranslateLoader(http: HttpClient, baseHref) {
// Temporary Azure hack
if (baseHref === null && typeof window !== 'undefined') {
baseHref = window.location.origin;
Expand All @@ -43,24 +48,33 @@ export function createTranslateLoader(http: Http, baseHref) {
UsersComponent,
UserDetailComponent,
HomeComponent,
// ChatComponent,
NotFoundComponent,
NgxBootstrapComponent
NgxBootstrapComponent,
CircularJsonPipe,
CoverSlideModuleComponent
],
imports: [
CommonModule,
HttpModule,
BrowserModule.withServerTransition({
appId: 'my-app-id' // make sure this matches with your Server NgModule
}),
HttpClientModule,
TransferHttpCacheModule,
BrowserTransferStateModule,


FormsModule,
ReactiveFormsModule,
FormlyModule.forRoot(),
FormlyBootstrapModule,
Ng2BootstrapModule.forRoot(), // You could also split this up if you don't want the Entire Module imported

TransferHttpModule, // Our Http TransferData method

// i18n support
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http, [ORIGIN_URL]]
deps: [HttpClient, [ORIGIN_URL]]
}
}),

Expand Down Expand Up @@ -145,9 +159,9 @@ export function createTranslateLoader(http: Http, baseHref) {
providers: [
LinkService,
UserService,
// ConnectionResolver,
TranslateModule
]
],
bootstrap: [AppComponent]
})
export class AppModuleShared {
}