forked from airtasker/spot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airtasker#1367 Implementation for SchemaProps (airtasker#1376)
- Loading branch information
Showing
28 changed files
with
1,784 additions
and
166 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
106 changes: 106 additions & 0 deletions
106
lib/src/generators/openapi2/__spec-examples__/contract-with-schemaprops.ts
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,106 @@ | ||
import { | ||
api, | ||
body, | ||
endpoint, | ||
headers, | ||
request, | ||
response, | ||
String, | ||
Integer, | ||
Float, | ||
Int64, | ||
Double | ||
} from "@airtasker/spot"; | ||
|
||
@api({ name: "contract" }) | ||
class Contract {} | ||
|
||
@endpoint({ | ||
method: "GET", | ||
path: "/users" | ||
}) | ||
class EndpointWithSchemaPropsOnHeaders { | ||
@request | ||
request( | ||
@headers | ||
headers: { | ||
/** property-schemaprop description for string | ||
* @oaSchemaProp minLength | ||
* 12 | ||
* @oaSchemaProp maxLength | ||
* 20 | ||
* @oaSchemaProp pattern | ||
* "^[0-9a-z_]+$" | ||
* */ | ||
status: String; | ||
/** property-schemaprop description for integer | ||
* @oaSchemaProp minimum | ||
* 1 | ||
* @default 42 | ||
* */ | ||
size: Integer; | ||
} | ||
) {} | ||
|
||
@response({ status: 200 }) | ||
successResponse( | ||
@body | ||
body: { | ||
id: String; | ||
name: String; | ||
/** property-schemaprop description for object | ||
* @oaSchemaProp minProperties | ||
* 1 | ||
* @oaSchemaProp maxProperties | ||
* 100 | ||
* */ | ||
element: { | ||
/** property-schemaprop description for float inner object | ||
* @oaSchemaProp example | ||
* 12.0 | ||
* @oaSchemaProp maximum | ||
* 99.95 | ||
* @oaSchemaProp multipleOf | ||
* 4 | ||
* */ | ||
price: Float; | ||
}; | ||
/** property-schemaprop description for array | ||
* @oaSchemaProp minItems | ||
* 1 | ||
* @oaSchemaProp maxItems | ||
* 5 | ||
* @oaSchemaProp uniqueItems | ||
* true | ||
* */ | ||
currencies?: String[]; | ||
/** property-schemaprop description for union | ||
* @oaSchemaProp title | ||
* "process-code" | ||
* */ | ||
code?: "VALID" | "NOT_VALID" | "WAITING" | "APPROVED"; | ||
/** property-schemaprop description for intersection | ||
* @oaSchemaProp title | ||
* "process-code" | ||
* */ | ||
inheritance?: { | ||
/** property-schemaprop description for double inner intersection | ||
* @oaSchemaProp example | ||
* 12.0 | ||
* @oaSchemaProp maximum | ||
* 99.95 | ||
* @oaSchemaProp multipleOf | ||
* 4 | ||
* */ | ||
inheritId: Double; | ||
} & { | ||
/** property-schemaprop description for long inner intersection | ||
* @oaSchemaProp minimum | ||
* 1 | ||
* @default 42 | ||
* */ | ||
inheritName: Int64; | ||
}; | ||
}[] | ||
) {} | ||
} |
Oops, something went wrong.