Forum Discussion

Stoplight's avatar
Stoplight
Community Manager
6 months ago

How to replicate the export function of Stoplight Desktop from the spectral CLI

Originally posted by user francbartoli to the Stoplight Community on 02/06/2023 at 14:12 ET.

I'm trying to bundle a remote schema with the spectral command line in order to get the same result of what I can have if I download the file [https://raw.githubusercontent.com/wmo-im/wcmp2/fix-schema/schemas/wcmpRecordGeoJSON.yaml](https://raw.githubusercontent.com/wmo-im/wcmp2/fix-schema/schemas/wcmpRecordGeoJSON.yaml), open it in Stoplight Desktop and use the Export Dialog.

I've tried to run the following spectral command:

docker run --rm -it -v $(pwd):/tmp stoplight/spectral lint documents https://raw.githubusercontent.com/wmo-im/wcmp2/fix-schema/schemas/wcmpRecordGeoJSON.yaml -r /tmp/.spectral.yaml -f json -o /tmp/bundled.json -v

but it is giving the following error as output: unrecognized-format.

Attached the bundled.json output and the link.yaml file referenced in the source that I'm mounting in the volume

Is this doable and the right approach?

$schema: https://json-schema.org/draft/2020-12/schema
$id: https://raw.githubusercontent.com/wmo-im/wcmp2/main/schema/link.yaml
title: WCMP 2 link object definition
description: WCMP 2 link object definition

allOf:
  - $ref: link.yaml
properties:
  security:
    type: object
    $ref: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.yaml#/definitions/Components/securitySchemes
  distribution:
    type: object
    description: the additional information qualifying the service and allowing to build and display the "access" information in a portal
    properties:
      availableFormats: 
        type: array 
        items: 
           type: object
           properties:
             name:
                type: string
                description: available format short name.
             description:
                type: string
                description: the individual format description to allow building the portal information
             numberOFiles:
                type: string
                description: typical number of files disseminated by the distribution mechanism over a period of time
             typicalFilesize:
                type: string
                description: size of a typical individual file (e.g. KB, MB, GB)
             typicalFilename:
                type: string
                description: example filename
             samples:
                type: object
                description: links of samples that can be openly accessed by users to provide a better understanding of the data
                items:
                  type: object
                  $ref: https://raw.githubusercontent.com/opengeospatial/ogcapi-records/master/core/openapi/schemas/common/link.yaml
             documentation:
                type: array
                description: links to the associated documentation available for this format when applicable
                items:
                  type: object
                  $ref: https://raw.githubusercontent.com/opengeospatial/ogcapi-records/master/core/openapi/schemas/common/link.yaml
  channel:
     type: string
     description: topic to subscribe to for broker workflow
[
	{
		"code": "unrecognized-format",
		"path": [],
		"message": "The provided document does not match any of the registered formats [OpenAPI 2.0 (Swagger), OpenAPI 3.x, OpenAPI 3.0.x, OpenAPI 3.1.x, AsyncAPI 2.0.x, AsyncAPI 2.1.x, AsyncAPI 2.2.x, AsyncAPI 2.3.x, AsyncAPI 2.4.x, AsyncAPI 2.5.x]",
		"severity": 1,
		"range": {
			"start": {
				"line": 0,
				"character": 0
			},
			"end": {
				"line": 94,
				"character": 21
			}
		},
		"source": "https://raw.githubusercontent.com/wmo-im/wcmp2/fix-schema/schemas/wcmpRecordGeoJSON.yaml"
	}
]
No RepliesBe the first to reply