Skip to content

Releases: aml-org/amf

Changes in 4.0.6

13 Mar 22:32
02f9958
Compare
Choose a tag to compare

Released Mar 13, 2020.

JS asset

JVM asset

Interface Changes

Changed bindings

New intermediate object was created to enable named bindings.

  • amf.client.model.domain.EndPoint.bindings changed its return type to amf.client.model.domain.ChannelBindings
  • amf.client.model.domain.Operation.bindings changed its return type to amf.client.model.domain.OperationBindings
  • amf.client.model.domain.Request.bindings changed its return type to amf.client.model.domain.MessageBindings
  • amf.client.model.domain.Response.bindings changed its return type to amf.client.model.domain.MessageBindings
  • amf.client.model.domain.Server.bindings changed its return type to amf.client.model.domain.ServerBindings

Example:

Before

val bindingsList List[ServerBinding] = EndPoint.bindings()

Now

val bindingsObject ChannelBindings  = EndPoint.bindings()
val bindingList List[ServerBinding] = bindingsObject.bindings()

This applies exactly the same with the interfaces mentioned before.

New bindings methods

  • amf.client.model.domain.EndPoint.withBindings (added)
  • amf.client.model.domain.Operation.withBindings (added)
  • amf.client.model.domain.Request.withBindings (added)
  • amf.client.model.domain.Response.withBindings (added)
  • amf.client.model.domain.Server.withBindings (added)

New validate method for payloads

If you are currently blocking the asynchronous payload validation call you can use the following new method:

  • amf.client.validate.PayloadValidator.syncValidate (synchronous)

OAS 2.0 Validation changes

Body parameters.

Duplicated body parameters are now being validated.
For example, the following api definition will now be invalid:

{
    "swagger": "2.0",
    "info": {
        "title": "Test",
        "version": "1.0.0"
    },
    "paths": {
        "/": {
            "parameters": [
                {
                    "name": "body parameter 1",
                    "in": "body",
                    "schema": {}
                },
                {
                    "name": "body parameter 2",
                    "in": "body",
                    "schema": {}
                }
            ],
            "get": {
                "responses": {
                    "200": {
                        "description": "ok"
                    }
                }
            }
        }
    }
}

Security requirement object

Security requirement object value is now being correctly validated as an array.

Valid example:

{
  "swagger" : "2.0",
  "info" : {
    "title" : "Registry",
    "version" : "1"
  },
  "paths" : {
  },
  "security" : [ {
    "Bearer" : []
  } ],
  "securityDefinitions" : {
    "Bearer" : {
      "in" : "header",
      "name" : "Authorization",
      "type" : "apiKey"
    }
  }
}

Invalid example:

{
  "swagger" : "2.0",
  "info" : {
    "title" : "Registry",
    "version" : "2"
  },
  "paths" : {
  },
  "security" : [ {
    "Bearer" : ""
  } ],
  "securityDefinitions" : {
    "Bearer" : {
      "in" : "header",
      "name" : "Authorization",
      "type" : "apiKey"
    }
  }
}

Info Object

Required facet "name" is now being validated.

Valid example:

{
    "swagger": "2.0",
    "info": {
        "title": "Testing API",
        "version": "1.0.0",
        "name": "my name",
        "license": {}
    },
    "paths": {}
}

Invalid example:

{
    "swagger": "2.0",
    "info": {
        "title": "Testing API",
        "version": "1.0.0",
        "license": {}
    },
    "paths": {}
}

AMF Fixed issues

Changes in 4.0.5

13 Feb 18:35
e229fde
Compare
Choose a tag to compare

Released Feb 13, 2020.

JS asset

JVM asset

Interface Changes

Async 2.0 Objects

New objects for Async 2.0 (beta)

  • amf.client.parse.Async20Parser

Compact json schema emission

When building a json schema from a shape (descendants of amf.client.model.domain.AnyShape), a new parsing option has been added to provide an alternative compacted emission. This extracts common types that are used throughout the resulting schema, and emits these schemas in the definitions facet.

shape.buildJsonSchema(ShapeRenderOptions().withCompactedEmission)

Validation changes

Improved validation of required facet in JSON schemas.

In JSON Schema 3 required facet is a boolean.
From JSON Schemas 4 & newer versions, it is an array (4 is used if no version is specified).

For example, the following schema definition will now be invalid:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "id": {
      "id": "id",
      "type": "string",
      "required": "true"
    }
  }
}

OAS 20 type parameter

Missing "type" facet in parameters are now validated, the following example is now invalid:

"parameters": [
          {
            "in": "query",
            "name": "filename",
            "required": true
          }
        ]

JSON Schema Properties

JSON Schema properties definitions are now validated, the following example that contains an array instead of an object for property definitions (usually a mistake using examples in the definitions) is now invalid:

{
  "$schema": "http://json-schema.org/schema",
  "type": "object",
  "properties": [
    {
      "date": "2019-10-21 13:31:17"
    },
    {
      "amount": "-13.00"
    }
  ]
}

Any JSON Schemas

JSON schemas with no types definition will now be validated correctly, for example the following raml is now valid:

types:
  Client:
    type: |
      {
        "$schema": "http://json-schema.org/draft-03/schema",
        "type": "object",
        "properties": {
          "from": {
            "required": true
          }
        }
      }
    example:
      {
        "from": "test"
      }

Before an Object was expected for the "from" value

AMF Fixed issues

Changes in 4.0.4

16 Jan 19:48
98ed701
Compare
Choose a tag to compare

Released Jan 16, 2020.

JS asset

JVM asset

OAS 3.0 full support

This version comes with full support of OAS 3.0, for adoption check EA release that contains the interface changes

Async API Early Access

This version is an Early Access to Async API support.
You have all API lifecycle development such as parse, resolve & some validations ready.
Take in mind that components object (and refs to it) & traits are still not supported.

Interface Changes

  • added amf.client.model.domain.Payload.schemaMediaType()
  • added amf.client.model.domain.Payload.withSchemaMediaType()
  • added amf.client.model.domain.SecurityScheme.withHttpApiKeySettings()
  • added amf.client.parse.Aml10Parser.parseAsync()
  • added amf.client.parse.JsonPayloadParser.parseAsync()
  • added amf.client.parse.Oas20Parser.parseAsync()
  • added amf.client.parse.Parser.parseAsync()
  • added amf.client.parse.Raml08Parser.parseAsync()
  • added amf.client.parse.Raml10Parser.parseAsync()
  • added amf.client.parse.RamlParser.parseAsync()
  • added amf.client.parse.YamlPayloadParser.parseAsync()
  • added amf.ProfileNames.ASYNC()
  • added amf.ProfileNames.ASYNC20()

Validation changes

Fixed invalid validation with repeat facet for RAML 0.8, for example the following api is now valid

securitySchemes: 
    - 
        oauth_2_0: 
            description: |
                Mule OAUTH.
            type: OAuth 2.0
            describedBy: 
                headers: 
                    Authorization: 
                        description: |
                            Used to send a valid OAuth 2 access token. Do not use 
                            with the "access_token" query string parameter.
                        type: string
                        required: false
                        repeat: true

AMF Fixed issues

Changes in 4.0.3

12 Dec 13:32
8c83c59
Compare
Choose a tag to compare

Released Nov 12, 2019.

JS asset

JVM asset

OAS 3.0 EA

This version comes with early access to OAS3.0 support.
Check interface changes for detail of new Objects.

JSON-LD model updated to version 2.0.0

Some namespaces of the fields have changed in the JSON-LD representation.
This change does not affect the use of the object model of AMF (interfaces remain the same).

Key changes in JSON-LD model

The key that identifies the name of an annotation has been changed from http://a.ml/vocabularies/document#name to http://a.ml/vocabularies/core#extensionName.

Interface Changes

OAS 3.0 Objects

New objects for OAS 3.0

  • amf.client.parse.Oas30Parser
  • amf.client.parse.Oas30YamlParser
  • amf.client.resolve.Oas30Resolver
  • amf.client.render.Oas30Renderer

Added Render Options

  • amf.client.render.RenderOptions.withNodeIds()
  • amf.client.render.RenderOptions.isEmitNodeIds()

Flattened

Flattened JSON-LD emission support for AMF (AML pending).
To use flattened emission use RenderOptions.withFlattenedJsonLd

  • New method amf.client.render.RenderOptions.withFlattenedJsonLd()
  • New method amf.client.render.RenderOptions.withoutFlattenedJsonLd()
  • New method amf.client.render.RenderOptions.isFlattenedJsonLd()

Security model changes

Security model in OAS3 has a change that affects compatibility, the property of security in WebApi, EndPoint and Operation that returned a List[ParametrizedSecurityScheme], now returns a List[SecurityRequirement]. SecurityRequirement is an object that contains a property schemes which is a List[ParametrizedSecurityScheme]. If there were three security schemes in the list before, now there will be three security requirements each with one security scheme, for example.
The second change is with the flows in an OAuth2Settings object. When accessing the settings of an OAuth 2 security scheme, there used to be some specific properties, now there is the authorizationGrants property and a flows property which contains a List[OAuth2Flow]. OAuth2Flow contains the other properties that used to be immediately in the settings of the scheme.

JSON Schema building

buildJsonSchema() available for Shapes:

  • amf.client.model.domain.UnionShape.buildJsonSchema()
  • amf.client.model.domain.DataArrangeShape.buildJsonSchema()
  • amf.client.model.domain.SchemaShape.buildJsonSchema()
  • amf.client.model.domain.MatrixShape.buildJsonSchema()
  • amf.client.model.domain.NilShape.buildJsonSchema()
  • amf.client.model.domain.TupleShape.buildJsonSchema()
  • amf.client.model.domain.AnyShape.buildJsonSchema()
  • amf.client.model.domain.ArrayShape.buildJsonSchema()
  • amf.client.model.domain.NodeShape.buildJsonSchema()

Validation changes

Enum value types in OAS are now properly validated, i.e. the following example is no longer valid.

"test": {
          "type": "string",
          "enum": 
            [{
              "key": "value"
            }]
}

Fixed invalid validation with !include tag, i.e. the following example is valid now (as it is considered a string payload)

#%RAML 1.0
title: test API

/resource:
  get:
    responses:
      200:
        body:
          application/json:
            example: !includedexample

Fixed wrong validation of additionalItems with values that are not Boolean, for example, the following schema is now valid:

{
      "$schema": "http://json-schema.org/draft-04/schema#",
      "type": "object",
      "description": "Allows the insertion of a Contact Us request into Unilever backend systems",
      "properties": {
          "consumer": {
              "type": "object",
              "properties": {
                  "contactDetail": {
                      "type": "array",
                      "minItems": 1,
                      "items": [
                          {
                              "type": "object",
                              "properties": {
                                  "id": {
                                      "type": "string"
                                  }
                              }
                          }
                      ],
                      "additionalItems": {
                          "type": "string"
                      }
                  }
              }
            }
        }
      }

Fixed a case in which a payload with null value for an optional enum used inside a trait was not correctly validated

AMF Fixed issues