Skip to main content
Version: Latest (0.56.x)

Data types

TypeSpec.Http​

AcceptedResponse​

The request has been accepted for processing, but processing has not yet completed.

model TypeSpec.Http.AcceptedResponse

Properties​

NameTypeDescription
statusCode202The status code.

ApiKeyAuth​

An API key is a token that a client provides when making API calls. The key can be sent in the query string:

GET /something?api_key=abcdef12345

or as a request header

GET /something HTTP/1.1
X-API-Key: abcdef12345

or as a cookie

GET /something HTTP/1.1
Cookie: X-API-KEY=abcdef12345
model TypeSpec.Http.ApiKeyAuth<Location, Name>

Template Parameters​

NameDescription
LocationThe location of the API key
NameThe name of the API key

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.apiKey
inLocation
nameName

AuthorizationCodeFlow​

Authorization Code flow

model TypeSpec.Http.AuthorizationCodeFlow

Properties​

NameTypeDescription
typeTypeSpec.Http.OAuth2FlowType.authorizationCodeauthorization code flow
authorizationUrlstringthe authorization URL
tokenUrlstringthe token URL
refreshUrl?stringthe refresh URL
scopes?string[]list of scopes for the credential

BadRequestResponse​

The server could not understand the request due to invalid syntax.

model TypeSpec.Http.BadRequestResponse

Properties​

NameTypeDescription
statusCode400The status code.

BasicAuth​

Basic authentication is a simple authentication scheme built into the HTTP protocol. The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password. For example, to authorize as demo / p@55w0rd the client would send

Authorization: Basic ZGVtbzpwQDU1dzByZA==
model TypeSpec.Http.BasicAuth

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.httpHttp authentication
scheme"basic"basic auth scheme

BearerAuth​

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name β€œBearer authentication” can be understood as β€œgive access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources:

Authorization: Bearer <token>
model TypeSpec.Http.BearerAuth

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.httpHttp authentication
scheme"bearer"bearer auth scheme

Body​

Defines a model with a single property of the given type, marked with @body.

This can be useful in situations where you cannot use a bare type as the body and it is awkward to add a property.

model TypeSpec.Http.Body<Type>

Template Parameters​

NameDescription
TypeThe type of the model's body property.

Properties​

NameTypeDescription
bodyType

ClientCredentialsFlow​

Client credentials flow

model TypeSpec.Http.ClientCredentialsFlow

Properties​

NameTypeDescription
typeTypeSpec.Http.OAuth2FlowType.clientCredentialsclient credential flow
tokenUrlstringthe token URL
refreshUrl?stringthe refresh URL
scopes?string[]list of scopes for the credential

ConflictResponse​

The request conflicts with the current state of the server.

model TypeSpec.Http.ConflictResponse

Properties​

NameTypeDescription
statusCode409The status code.

CreatedResponse​

The request has succeeded and a new resource has been created as a result.

model TypeSpec.Http.CreatedResponse

Properties​

NameTypeDescription
statusCode201The status code.

ForbiddenResponse​

Access is forbidden.

model TypeSpec.Http.ForbiddenResponse

Properties​

NameTypeDescription
statusCode403The status code.

HeaderOptions​

Header options.

model TypeSpec.Http.HeaderOptions

Properties​

NameTypeDescription
name?stringName of the header when sent over HTTP.
format?"csv" | "multi" | "tsv" | "ssv" | "pipes" | "simple" | "form"Determines the format of the array if type array is used.

ImplicitFlow​

Implicit flow

model TypeSpec.Http.ImplicitFlow

Properties​

NameTypeDescription
typeTypeSpec.Http.OAuth2FlowType.implicitimplicit flow
authorizationUrlstringthe authorization URL
refreshUrl?stringthe refresh URL
scopes?string[]list of scopes for the credential

LocationHeader​

The Location header contains the URL where the status of the long running operation can be checked.

model TypeSpec.Http.LocationHeader

Properties​

NameTypeDescription
locationstringThe Location header contains the URL where the status of the long running operation can be checked.

MovedResponse​

The URL of the requested resource has been changed permanently. The new URL is given in the response.

model TypeSpec.Http.MovedResponse

Properties​

NameTypeDescription
statusCode301The status code.
locationstringThe Location header contains the URL where the status of the long running operation can be checked.

NoAuth​

This authentication option signifies that API is not secured at all. It might be useful when overriding authentication on interface of operation level.

model TypeSpec.Http.NoAuth

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.noAuth

NoContentResponse​

There is no content to send for this request, but the headers may be useful.

model TypeSpec.Http.NoContentResponse

Properties​

NameTypeDescription
statusCode204The status code.

NotFoundResponse​

The server cannot find the requested resource.

model TypeSpec.Http.NotFoundResponse

Properties​

NameTypeDescription
statusCode404The status code.

NotModifiedResponse​

The client has made a conditional request and the resource has not been modified.

model TypeSpec.Http.NotModifiedResponse

Properties​

NameTypeDescription
statusCode304The status code.

OAuth2Auth​

OAuth 2.0 is an authorization protocol that gives an API client limited access to user data on a web server.

OAuth relies on authentication scenarios called flows, which allow the resource owner (user) to share the protected content from the resource server without sharing their credentials. For that purpose, an OAuth 2.0 server issues access tokens that the client applications can use to access protected resources on behalf of the resource owner. For more information about OAuth 2.0, see oauth.net and RFC 6749.

model TypeSpec.Http.OAuth2Auth<Flows, Scopes>

Template Parameters​

NameDescription
FlowsThe list of supported OAuth2 flows
ScopesThe list of OAuth2 scopes, which are common for every flow from Flows. This list is combined with the scopes defined in specific OAuth2 flows.

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.oauth2
flowsFlows
defaultScopesScopes

OkResponse​

The request has succeeded.

model TypeSpec.Http.OkResponse

Properties​

NameTypeDescription
statusCode200The status code.

OpenIdConnectAuth​

OpenID Connect (OIDC) is an identity layer built on top of the OAuth 2.0 protocol and supported by some OAuth 2.0 providers, such as Google and Azure Active Directory. It defines a sign-in flow that enables a client application to authenticate a user, and to obtain information (or "claims") about that user, such as the user name, email, and so on. User identity information is encoded in a secure JSON Web Token (JWT), called ID token. OpenID Connect defines a discovery mechanism, called OpenID Connect Discovery, where an OpenID server publishes its metadata at a well-known URL, typically

https://server.com/.well-known/openid-configuration
model TypeSpec.Http.OpenIdConnectAuth<ConnectUrl>

Template Parameters​

NameDescription
ConnectUrl

Properties​

NameTypeDescription
typeTypeSpec.Http.AuthType.openIdConnectAuth type
openIdConnectUrlConnectUrlConnect url. It can be specified relative to the server URL

PasswordFlow​

Resource Owner Password flow

model TypeSpec.Http.PasswordFlow

Properties​

NameTypeDescription
typeTypeSpec.Http.OAuth2FlowType.passwordpassword flow
tokenUrlstringthe token URL
refreshUrl?stringthe refresh URL
scopes?string[]list of scopes for the credential

PlainData​

Produces a new model with the same properties as T, but with @query, @header, @body, and @path decorators removed from all properties.

model TypeSpec.Http.PlainData<Data>

Template Parameters​

NameDescription
DataThe model to spread as the plain data.

Properties​

None

QueryOptions​

Query parameter options.

model TypeSpec.Http.QueryOptions

Properties​

NameTypeDescription
name?stringName of the query when included in the url.
format?"multi" | "csv" | "ssv" | "tsv" | "simple" | "form" | "pipes"Determines the format of the array if type array is used.

Response​

Describes an HTTP response.

model TypeSpec.Http.Response<Status>

Template Parameters​

NameDescription
StatusThe status code of the response.

Properties​

NameTypeDescription
statusCodeStatus

UnauthorizedResponse​

Access is unauthorized.

model TypeSpec.Http.UnauthorizedResponse

Properties​

NameTypeDescription
statusCode401The status code.

ApiKeyLocation​

Describes the location of the API key

enum TypeSpec.Http.ApiKeyLocation

AuthType​

Authentication type

enum TypeSpec.Http.AuthType

OAuth2FlowType​

Describes the OAuth2 flow type

enum TypeSpec.Http.OAuth2FlowType