Removed unused feature.

Optimized use statements in main.

Simplified truth_combinations code a little.

Updated OpenAPI spec
This commit is contained in:
Martin Berg Alstad
2024-06-22 20:38:55 +02:00
parent 38fc8ce383
commit 1b94e63915
11 changed files with 566 additions and 86 deletions

View File

@ -1,38 +1,75 @@
import "@typespec/http";
import "@typespec/versioning";
import "./models.tsp";
import "./response.tsp";
import "./options.tsp";
using TypeSpec.Http;
using TypeSpec.Versioning;
using Models;
using Responses;
using Options;
/**
* A service to simplify truth expressions, and generate truth tables.
*/
@service({
title: "Simplify Truth API",
})
@versioned(Version)
namespace SimplifyTruths;
enum Version {
v2
v2,
}
@versioned(Version)
@service({
title: "Simplify Truth Expressions",
description: "Simplify truth expressions",
})
namespace Simplify {
model SimplifyResponse {
before: string;
after: string;
orderOfOperations?: string[] = [];
expression: Expression;
}
@tag("Common")
interface Index {
/**
* Information about this API.
*/
@get
@summary("Information")
index(): InfoResponse;
model SimplifyOptions {
lang: "en" | "nb" = "en";
simplify: boolean = true;
caseSensitive: boolean = false;
}
/**
* The OpenAPI specification for this API.
*/
@get
@route("/openapi")
@summary("The OpenAPI specification")
openAPI(): HTML;
@route("/simplify")
interface Simplify {
@get op simplify(
@path exp: string,
@query query?: SimplifyOptions
): SimplifyResponse;
}
/**
* Check if an expression is valid.
*/
@get
@tag("Expression")
@route("/is-valid")
@summary("Check if an expression is valid")
isValid(@path exp: string): IsValidResponse;
}
@tag("Expression")
@route("/simplify")
interface Simplify {
@get
@summary("Simplify a truth expression")
simplify(@path exp: string, @query query?: SimplifyOptions): SimplifyResponse;
@get
@tag("Table")
@route("/table")
@summary("Simplify and generate a truth table")
simplifyTable(
@path exp: string,
@query query?: SimplifyTableOptions,
): SimplifyTableResponse;
}
@tag("Table")
@route("/table")
interface TruthTable {
@get
@summary("Generate a truth table")
simplify(@path exp: string, @query query?: TableOptions): TruthTableResponse;
}