Skip to content

Instantly share code, notes, and snippets.

Avatar

Hakan Tuncer hakant

View GitHub Profile
View swashbuckle-versioning-asp.net-core-startup-pseudo.cs
/// <summary>
/// Represents the startup process for the application.
/// </summary>
public class Startup
{
/// <summary>
/// Configures services for the application.
/// </summary>
/// <param name="services">The collection of services to configure the application with.</param>
public void ConfigureServices(IServiceCollection services)
View swashbuckle-versioning-asp.net-core-startup.cs
namespace Microsoft.Examples
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
View swagger-and-versioning-packages.xml
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
View import-api-to-azure-api-management-with-versioning.ps1
param(
[string]$tenantId = "",
[string]$subscriptionId = "",
[string]$resourceGroupName = "",
[string]$apimServiceName = "",
[string]$clientId = "",
[string]$clientSecret = "",
[string]$apiName = "",
[string]$backendUrl = "",
[bool] $apiContainsMultipleVersions = $true
View add-api-versioning.cs
services.AddApiVersioning(o => o.ReportApiVersions = true);
View action-level-versioning.cs
[ApiVersion("1.0")]
[ApiVersion("2.0")]
[Route("api/home")]
public class HomeController : Controller
{
[HttpGet]
public string Get() => "Version 1";
[HttpGet, MapToApiVersion("2.0")]
public string GetV2() => "Version 2";
View Sample API V3 - Swagger.json
{
"swagger":"2.0",
"info":{
"version":"3.0",
"title":"Sample API 3.0",
"description":"A sample application with Swagger, Swashbuckle, and API versioning."
},
"paths":{
"/api/v3/People":{
"get":{
View .travis.yml
sudo: required
dist: trusty
language: node_js
node_js:
- '7.7.4'
services:
- docker
addons:
View InsertAndGetIdeasSpec-1.ts
"use strict";
import * as nconf from 'nconf';
nconf.argv().env().file({ file: 'config.json' });
import databaseSetup from "../../infrastructure/DatabaseSetup";
import application from "../../application/application";
import { GetIdeasRequest, GetIdeasResponse } from "../../scenarios/GetIdeas";
import { InsertIdeaRequest, InsertIdeaResponse } from "../../scenarios/InsertIdea";
View Ideas-Route.ts
router.get('/', catchAsyncErrors(async function (req, res, next) {
var request = new GetIdeasRequest();
request.user = req.user;
var response = await application.ExecuteAsync<GetIdeasRequest, GetIdeasResponse>(request);
res.json(response.ideas);
}));