Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions specmatic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ dependencies:
specmatic:
governance:
successCriteria:
minCoveragePercentage: 70
maxMissedOperationsInSpec: 4
minCoveragePercentage: 50
enforce: true
settings:
test:
Expand Down
6 changes: 4 additions & 2 deletions test/apps/fast_api/orders/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter
from fastapi import APIRouter, HTTPException, Request

from ..schemas import Order
from ..services import OrdersService
Expand All @@ -7,6 +7,8 @@


@orders.post("/orders", status_code=201)
async def create_order(order: Order) -> dict[str, int]:
async def create_order(request: Request, order: Order) -> dict[str, int]:
if request.headers.get("content-type", "").split(";")[0].strip() != "application/json":
raise HTTPException(status_code=415, detail="Unsupported Media Type")
new_order = await OrdersService.create_order(order)
return {"id": new_order["id"]}
6 changes: 4 additions & 2 deletions test/apps/fast_api/products/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Header, HTTPException
from fastapi import APIRouter, Header, HTTPException, Request
from fastapi.responses import JSONResponse

from ..schemas import Product, ProductType
Expand All @@ -23,6 +23,8 @@ async def find_available_products(


@products.post("/products", status_code=201)
async def add_product(data: Product) -> dict[str, int]:
async def add_product(request: Request, data: Product) -> dict[str, int]:
if request.headers.get("content-type", "").split(";")[0].strip() != "application/json":
raise HTTPException(status_code=415, detail="Unsupported Media Type")
product = await ProductService.create_product(data)
return {"id": product["id"]}
4 changes: 3 additions & 1 deletion test/apps/flask_app/orders/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, jsonify, request
from flask import Blueprint, abort, jsonify, request

from ..orders.models import Order
from ..services import OrdersService
Expand All @@ -8,6 +8,8 @@

@orders.route("/orders", methods=["POST"])
def create_order():
if request.content_type != "application/json":
abort(415, "Unsupported Media Type")
data: Order = Order.load(request.json)
order = OrdersService.create_order(data)
return jsonify(id=order["id"]), 201
2 changes: 2 additions & 0 deletions test/apps/flask_app/products/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def find_available_products():

@products.route("/products", methods=["POST"])
def add_product():
if request.content_type != "application/json":
abort(415, "Unsupported Media Type")
data: Product = Product.load(request.json)
product = ProductService.create_product(data)
return jsonify(id=product["id"]), 201
3 changes: 3 additions & 0 deletions test/apps/sanic_app/orders/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING

from sanic import Blueprint, json
from sanic.exceptions import SanicException

from ..orders.models import Order
from ..services import OrdersService
Expand All @@ -13,6 +14,8 @@

@orders.route("/orders", methods=["POST"])
async def create_order(request: "Request"):
if request.headers.get("content-type", "").split(";", 1)[0].strip() != "application/json":
raise SanicException("Unsupported Media Type", status_code=415)
data: Order = Order.load(request.json)
order = OrdersService.create_order(data)
return json({"id": order["id"]}, status=201)
3 changes: 3 additions & 0 deletions test/apps/sanic_app/products/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING

from sanic import Blueprint, json
from sanic.exceptions import SanicException
from sanic.exceptions import ServiceUnavailable

from ..products.models import Product
Expand All @@ -26,6 +27,8 @@ async def find_available_products(request: "Request"):

@products.route("/products", methods=["POST"])
async def add_product(request: "Request"):
if request.headers.get("content-type", "").split(";", 1)[0].strip() != "application/json":
raise SanicException("Unsupported Media Type", status_code=415)
data: Product = Product.load(request.json)
product = ProductService.create_product(data)
return json({"id": product["id"]}, status=201)
Loading