Validating the YAML or JSON definition of an API or Product

You can validate a YAML or JSON definition by using the IBM® API Connect developer toolkit.

Before you begin

To complete the steps that are described in this topic, you must have installed the developer toolkit. For more information, see Installing the toolkit.

Procedure

To perform validation by using the developer toolkit, enter the following command:
apic validate filename

where filename is the file name of the API definition file you want to validate.

  • Include --product-only to validate only a Product definition and not any APIs that it references.
  • Include --no-extensions to validate only the default OpenAPI section of the API and none of its extensions.
Note:
  • If the OpenAPI file that defines your API uses a $ref field to reference a fragment of OpenAPI code that is defined in a separate file, the $ref field is replaced with the contents of the target file before the draft API is created with the apic drafts:validate command. For more information, see Using $ref to reuse code fragments in your OpenAPI files.
  • Products that contain an API with a Swagger property using regex that include lookahead assertions, such as "(?" cannot be validated or published. An error message is returned. For example:
    Product has not been published!
    The multipart 'openapi' field contains an OpenAPI definition with validation errors.
        definitions.properties.pattern Does not match format 'regex' (context: (root).definitions.properties.pattern, line: 0, col: 0)
    400