Skip to content

Instantly share code, notes, and snippets.

@crgrieve
crgrieve / Startup.cs
Last active January 10, 2021 14:31
.Net 5 WebAPI Startup config for Swagger
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
namespace CaroleExampleApp
{
public class Startup
@crgrieve
crgrieve / BlogController.cs
Created January 10, 2021 14:54
.Net 5 example WebAPI controller
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CaroleExampleApp.Controllers
{
[ApiController]
@crgrieve
crgrieve / swagger.json
Created January 10, 2021 15:54
Swagger JSON example
{
"openapi": "3.0.1",
"info": {
"title": "CaroleExampleApp",
"version": "v1"
},
"paths": {
"/Blog": {
"get": {
"tags": [
@crgrieve
crgrieve / BlogController.cs
Created April 6, 2021 15:48
Umbraco dotnet core controller
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Umbraco.Cms.Core;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Extensions;
using Umbracov9AlphaAPIs.APIModels;
namespace Umbracov9AlphaAPIs.Controllers
{
public class BlogController : UmbracoApiController
@crgrieve
crgrieve / Startup.cs
Last active May 2, 2023 11:40
Umbraco v9 startup.cs with Swagger
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.UI.NetCore
@crgrieve
crgrieve / BlogController.cs
Created April 6, 2021 16:08
Umbraco dotnet core API controller with annotations
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Umbraco.Cms.Core;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Extensions;
using Umbracov9AlphaAPIs.APIModels;
namespace Umbracov9AlphaAPIs.Controllers
{
[ApiController]
@crgrieve
crgrieve / BlogPostModel
Created April 6, 2021 16:21
A model class to return from our API contoller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Umbracov9AlphaAPIs.APIModels
{
public class BlogPostModel
{
public string Title { get; init; }
global using System;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
@crgrieve
crgrieve / Program.cs
Created July 2, 2021 20:17
An example Program.cs for Umbraco v9 project with usings refactored to a global file.
namespace DotNet6Umbraco
{
public class Program
{
public static void Main(string[] args)
=> CreateHostBuilder(args)
.Build()
.Run();
public static IHostBuilder CreateHostBuilder(string[] args) =>
@crgrieve
crgrieve / Startup.cs
Last active July 2, 2021 20:45
An example Startup.cs for Umbraco v9 project with some usings refactored to a global file.
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
namespace DotNet6Umbraco
{
public class Startup
{