This repository has been archived by the owner on Jun 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for OpenAPI v3 schema rendering. (#5)
- Loading branch information
Showing
32 changed files
with
973 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export * from "./openApiComponents"; | ||
export * from "./openApiExample"; | ||
export * from "./openApiExternalDoc"; | ||
export * from "./openApiMediaType"; | ||
export * from "./openApiObjectInfo"; | ||
export * from "./openApiOperation"; | ||
export * from "./openApiParameter"; | ||
export * from "./openApiPath"; | ||
export * from "./openApiPaths"; | ||
export * from "./openApiReference"; | ||
export * from "./openApiRequestBody"; | ||
export * from "./openApiResponse"; | ||
export * from "./openApiResponses"; | ||
export * from "./openApiSchema"; | ||
export * from "./openApiServer"; | ||
export * from "./openApiTag"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
OpenApiComponents, | ||
OpenApiExternalDoc, | ||
OpenApiObjectInfo, | ||
OpenApiPaths, | ||
OpenApiServer, | ||
OpenApiTag | ||
} from "./"; | ||
|
||
/** | ||
* This is the root document object of the | ||
*/ | ||
export interface OpenApiSpec30 { | ||
/** | ||
* This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document uses. | ||
*/ | ||
openapi: string; | ||
|
||
/** | ||
* The available paths and operations for the API. | ||
*/ | ||
paths: OpenApiPaths; | ||
|
||
/** | ||
* Provides metadata about the API. The metadata MAY be used by tooling as required. | ||
*/ | ||
info: OpenApiObjectInfo; | ||
|
||
/** | ||
* Additional external documentation. | ||
*/ | ||
externalDocs?: OpenApiExternalDoc; | ||
|
||
/** | ||
* An array of Server Objects, which provide connectivity information to a target server. | ||
* If the servers property is not provided, or is an empty array, the default value would | ||
* be a Server Object with a URL value of /. | ||
*/ | ||
servers?: OpenApiServer[]; | ||
|
||
/** | ||
* A list of tags used by the specification with additional metadata. | ||
*/ | ||
tags?: OpenApiTag[]; | ||
|
||
/** | ||
* An element to hold various schemas for the specification. | ||
*/ | ||
components: OpenApiComponents; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface OpenApiComponents { | ||
schemas?: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface OpenApiExample { | ||
/** | ||
* Short description for the example. | ||
*/ | ||
summary: string; | ||
|
||
/** | ||
* Long description for the example. | ||
*/ | ||
description: string; | ||
|
||
/** | ||
* Embedded literal example. The value field and externalValue field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. | ||
*/ | ||
value: any; | ||
|
||
/** | ||
* A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The value field and externalValue field are mutually exclusive. | ||
*/ | ||
externalValue: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface OpenApiExternalDoc { | ||
url: string; | ||
description?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { OpenApiExample } from "./openApiExample"; | ||
|
||
|
||
export interface OpenApiMediaType { | ||
schema: any; // OpenApiSchema | OpenApiReference; | ||
example: OpenApiExample; | ||
examples: any; | ||
encoding: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface OpenApiObjectInfo { | ||
title: string; | ||
description?: string; | ||
version: string; | ||
termsOfService?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { OpenApiParameter } from "./openApiParameter"; | ||
import { OpenApiResponses } from "./openApiResponses"; | ||
import { OpenApiRequestBody } from "./openApiRequestBody"; | ||
|
||
|
||
export interface OpenApiOperation { | ||
operationId: string; | ||
description: string; | ||
parameters: OpenApiParameter[]; | ||
responses: OpenApiResponses; | ||
summary: string; | ||
consumes?: string[]; | ||
produces?: string[]; | ||
requestBody?: OpenApiRequestBody; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface OpenApiParameter { | ||
name: string; | ||
in: string; | ||
required: boolean; | ||
description: string; | ||
type?: string; | ||
schema?: any; | ||
default?: string; | ||
enum: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { OpenApiOperation } from "./openApiOperation"; | ||
|
||
|
||
export interface OpenApiPath { | ||
[key: string]: OpenApiOperation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { OpenApiPath } from "./openApiPath"; | ||
|
||
export interface OpenApiPaths { | ||
[key: string]: OpenApiPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface OpenApiReference { | ||
$ref: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Bag } from "@paperbits/common"; | ||
import { OpenApiMediaType } from "./openApiMediaType"; | ||
|
||
/** | ||
* Describes a single request body. | ||
*/ | ||
export interface OpenApiRequestBody { | ||
/** | ||
* A brief description of the request body. This could contain examples of use. | ||
*/ | ||
description: string; | ||
|
||
/** | ||
* Determines if the request body is required in the request. Defaults to false. | ||
*/ | ||
required: boolean; | ||
|
||
/** | ||
* The content of the request body. The key is a media type or media type range and the value describes it. | ||
* For requests that match multiple keys, only the most specific key is applicable, | ||
* e.g. text/plain overrides text/* | ||
*/ | ||
content: Bag<OpenApiMediaType>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Bag } from "@paperbits/common"; | ||
import { OpenApiMediaType } from "./openApiMediaType"; | ||
import { OpenApiParameter } from "./openApiParameter"; | ||
|
||
|
||
export interface OpenApiResponse { | ||
description: string; | ||
headers: Bag<OpenApiParameter>; | ||
content: Bag<OpenApiMediaType>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { OpenApiResponse } from "./openApiResponse"; | ||
|
||
export interface OpenApiResponses { | ||
[key: string]: OpenApiResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface OpenApiSchema { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export interface OpenApiServer { | ||
url: string; | ||
description?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { OpenApiExternalDoc } from "./openApiExternalDoc"; | ||
|
||
|
||
export interface OpenApiTag { | ||
name: string; | ||
description?: string; | ||
externalDocs?: OpenApiExternalDoc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { ParameterContract } from "./parameter"; | ||
import { RepresentationContract } from "./representation"; | ||
|
||
/* | ||
Model of API operation request | ||
*/ | ||
/** | ||
* Model of API operation request | ||
*/ | ||
export interface RequestContract { | ||
description?: string; | ||
queryParameters: ParameterContract[]; | ||
headers: ParameterContract[]; | ||
representations: RepresentationContract[]; | ||
queryParameters?: ParameterContract[]; | ||
headers?: ParameterContract[]; | ||
representations?: RepresentationContract[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.