AMF (API Modeling Framework)
website·Indexed 33 days ago
https://a.ml/docs/A framework for parsing, modeling, validating, and emitting API specifications. AMF supports various API specifications, JSON Schema, and GraphQL Subgraph APIs, utilizing AML (Anything Modeling Language) for defining metadata documents. The documentation covers versions 4.x.x and v5.x.x, including guides on payload validation, model resolution pipelines, and conversion goals.
What's inside AMF
- AMF is an open-source library written in Scala.js used for parsing and validating AML metadata documents. It can be executed in the JVM, Node.js, or a web browser, and is available as both a standalone command-line tool and a library for Scala, Java, and JavaScript/Node.js applications.
Overview of AMF Parsing capabilities
v4AMF (v4.x.x) parses AML dialects and several common API specifications into a model graph. It uses SYAML to read JSON or YAML files and generate an Abstract Syntax Tree (AST), which is then converted into a
BaseUnitobject. ThisBaseUnitcan be aFragment,Module,Document, or other type, representing either a Web API model or an AML document model.Supported specifications include:
- RAML 0.8 and 1.0
- OpenAPI Specification (OAS) 2.0 and 3.0
- AsyncAPI 2.0
Overview of the AMF Custom Validator
Starting with AMF version 5.x.x, the Custom Validation feature is no longer part of the AMF core and has been moved to a standalone project: AMF Custom Validator. The validator operates by taking AMF JSON-LD output as the data input and a Ruleset (formerly known as a Validation Profile) as the constraints to generate a validation report.Overview of Anything Modeling Language (AML)
v4AML (Anything Modeling Language) is a declarative language used to define metadata documents that are parsed into graphs of information. It allows developers to describe existing YAML/JSON metadata or create new metadata formats with formal semantics, explicit schemas for validation, and support for W3C recommendations. AML documents can be published as linked data on the web or via APIs and are typically translated into JSON-LD for storage in graph databases.Overview of AMF (AML Modeling Framework)
v4AMF is an open-source library written in Scala.js used for parsing and validating AML metadata documents. It allows developers to describe syntactic models (language-specific) and semantic models (industry/domain-specific), storing them in a unified data graph. AMF can be executed in the JVM, Node.js, or a browser, and is available as both a standalone CLI tool and a library for Scala, Java, and JavaScript/TypeScript applications.Overview of Anything Modeling Language (AML)
AML (Anything Modeling Language) is a declarative language used to define metadata documents that parse into graphs of information. It allows developers to describe existing YAML/JSON metadata or define new metadata formats with formal semantics, explicit schemas for validation, and support for W3C web recommendations. AML documents can be published as APIs or linked on the web and are designed to be stored in and queried by graph databases.Overview of AML Modeling Framework (AMF)
AMF (AML Modeling Framework) is an open-source library used to parse, transform, validate, and render arbitrary models. It provides specialized out-of-the-box support for API models, specifically working with RAML, OAS (OpenAPI Specification), and AsyncAPI. For non-API models, users can define custom models using AML Vocabularies and Dialects.Overview of AMF model validation
v4Validation in AMF 4.x.x is the process of checking if a model complies with defined constraints. Validation is performed after the model has been parsed and resolved. There are two primary types of validations:
- Web API validations: Programmatic constraints validated against the WebApi model. These include general validations and specification-specific validations for every API spec supported by AMF.
- SHACL validations: Uses Shapes Constraint Language (SHACL) to validate conditions against RDF graphs (such as the AMF Graph). This is primarily used for validating AML dialect instances.
Use AMF with Apollo Federation v2
AMF (v5.x.x) supports APIs defined as GraphQL Subgraph APIs compliant with the Apollo Federation v2 specification. To get started with Federation in AMF, use theGraphQLFederationConfiguration.Convert API specifications using AMF
AMF supports cross-parsing and rendering of API specifications. This process involves parsing a source specification into an AMF API Contract Model and then using a 'Compatibility resolution' pipeline to adapt that model to meet the requirements of a target specification. The primary goal is to output a valid API Contract Model for the target spec while minimizing information loss.Understand AMF JSON Schema Draft 2019-09 to Draft 7 translation
v4AMF 4.x.x supports parsing and emission of JSON Schema Draft 2019-09 (required for OpenAPI 3.1). However, because the underlying validators (Ajv for JS and Everit for JVM) do not support Draft 2019-09, AMF cross-emits these schemas to Draft 7 for validation purposes. This translation may result in different schema paths in error messages compared to the original Draft 2019-09 schema.Use AVRO Schemas in AMF
AMF v5.x.x supports the AVRO Schema 1.9.0 specification. AVRO schemas are supported in two primary contexts:
- Standalone Documents: Defined as
.jsonor.avscfiles. These require the use ofAvroConfigurationand theAvroSchemaDocumenttype for parsing. - AsyncAPI Message Payloads: Supported inline or via
$refwithin a message payload. TheschemaFormatkey must be explicitly declared to specify the AVRO payload version.
Unsupported: AVRO Schemas are NOT supported inside the
components/schemassection of an AsyncAPI document because AMF cannot reliably determine the schema type in that location.- Standalone Documents: Defined as