RepreZen / Semoasa

Specification Extension Metadata for OAS Annotations (Semoasa) is a machine-readable format for extensions to Swagger/OpenAPI 2.0 and 3.0 specifications.
29 stars 1 forks source link
catalog custom customization extensibility format listing openapi properties registry repository specification-extensions standardized standards swagger vendor-extensions

Semoasa - Specification Extension Metadata for OAS Annotations (DRAFT)

Background

The OpenAPI Specification, formerly known as the Swagger Specification, is a standard, machine-readable format for REST-style API definitions and documentation. Swagger 2.0 introduced vendor extensions, which allow certain objects to have properties named with an x- prefix, with arbitrary or independently specified property values. Vendor extensions were later renamed to specification extensions in OpenAPI 2.0 and 3.0.

Motivation

While specification extensions are widely used, there is no standardized way to define their syntax, expected values, and allowed usage context. This makes it much more difficult for OpenAPI tools to support specification extensions with content assist, validation, and other features that those tools typically provide for standard OpenAPI language constructs.

For example, an OpenAPI editor will usually have design-time knowledge of the OpenAPI specification, and may make use of a JSON Schema that encodes some of this knowledge. Based on this knowledge, it can provide context-sensitive editing assistance and validation. But if the user adds extended properties with the x- prefix, the trail goes cold. Unless the editor has been designed with explicit prior knowledge of that specification extension, it can't tell the user what the extended property means, what kinds of values are expected, and whether that extension is even meaningful in this context.

Semoasa is a machine-readable format for specification extensions that provides a base level of structural and descriptive information, along with optional links to external resources for human-readable documentation. Like OpenAPI itself, specification extensions may have certain constraints and semantics that aren't captured in a schema or metadata descriptor; but the information carried in Semoasa is sufficient to allow OpenAPI tools to provide a user experience much closer to what they provide for standard OpenAPI syntax.

Use Cases

Roles

Semoasa use cases involve interactions among systems or system implementors in different roles:

Catalog Patterns

Publishers and consumers may want to exchange catalogs in different forms:

Tool Functions

Semoasa is designed with a few representative use cases in mind

Design Goals

Semoasa aims to meet the following goals, to the extent practical:

Structure

Once the Semoasa format gets some traction and achieves a level of stability, we'll write a formal specification. For now, this outline format summarizes the structure of a Semoasa document:

Examples

Here's a starting example:

openapiExtensionFormat: 0.1.0
com.amazon.aws:
  x-amazon-apigateway-integration:
    summary: Specifies the integration of the method with the backend.
    description: |
      Specifies details of the backend integration used for this method. 
      This extension is an extended property of the Swagger Operation object.
      The result is an API Gateway integration object.
    externalDocs:
      description: AWS documentation page in the  Amazon API Gateway Developer Guide 
      url: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html
    provider:
      name: Amazon Web Services
      url: https://aws.amazon.com/
    schema: 
      type: object
      properties:
        cacheKeyParameters:
          type: array
          items:
            type: string
          description: A list of request parameters whose values are to be cached.
        cacheNamespace:
          type: string
          description: An API-specific tag group of related cached parameters.
        credentials:
          type: string  
          description: |
            For AWS IAM role-based credentials, specify the ARN of an appropriate IAM role. 
            If unspecified, credentials will default to resource-based permissions that must
            be added manually to allow the API to access the resource. For more information,
            see Granting Permissions Using a Resource Policy. 
        contentHandling: 
          type: string
          description: |
            Request payload encoding conversion types. Valid values are 
            1) CONVERT_TO_TEXT, for converting a binary payload into a Base64-encoded string 
            or converting a text payload into a utf-8-encoded string or passing through the 
            text payload natively without modification, and 
            2) CONVERT_TO_BINARY, for converting a text payload into Base64-decoded blob or 
            passing through a binary payload natively without modification.
        httpMethod:
          type:  string
          description: |
            The HTTP method used in the integration request. For Lambda function invocations, 
            the value must be POST.
        #... (other properties)
    oas2:
      usage: restricted
      objectTypes:
      - OperationObject
    oas3:
      usage: restricted
      objectTypes:
      - OperationObject

Implementations

Further implementations coming soon, pending review and adoption of the specification by tool providers.

Project Description Language Website/Example
widdershins OpenApi / Swagger, AsyncApi & Semoasa definition to Slate / Shins compatible markdown Node.js APIs.guru extension documentation

Resources

Contributing to Semoasa

Please comment! This is an early DRAFT specification. We need input from OAS tool providers, extension providers, the OpenAPI TDC, and other interested parties.

Please review the open issues, feel free to comment on these, and open new issues.