Skip to content

neynarxyz/OAS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAS

Validate and Lint OpenAPI Specs

Overview

The OpenAPI specification for the Neynar APIs. Sign up for an API key on neynar.com.

Installing Spectral for OpenAPI Validation

We use Spectral to lint and validate our OpenAPI specifications. Spectral helps ensure that the OpenAPI files are compliant with the OpenAPI specification and follow best practices.

Install Spectral

You can install Spectral globally using Yarn:

yarn global add @stoplight/spectral-cli

Validating OpenAPI Specifications

To validate an OpenAPI specification file using Spectral, run:

v1

spectral lint src/v1/spec.yaml

v2

spectral lint src/v2/spec.yaml

hub-rest-api

spectral lint src/hub-rest-api/spec.yaml

Spectral will output any errors or warnings found in the specification files.

Validating OpenAPI Specifications with Swagger

In addition to Spectral, you can use the Swagger CLI to validate your OpenAPI specifications.

Install Swagger CLI

You can install Swagger CLI globally using Yarn:

yarn global add swagger-cli

Validate OpenAPI Specifications with Swagger CLI

To validate an OpenAPI specification file using Swagger CLI, run:

v1

swagger-cli validate src/v1/spec.yaml

v2

swagger-cli validate src/v2/spec.yaml

hub-rest-api

swagger-cli validate src/hub-rest-api/spec.yaml

This will check for structural errors and report any issues.

Installing Client Code Generator

We use OpenAPI Generator to generate client code from the OpenAPI specifications.

Install OpenAPI Generator

Prerequisite: Java must be installed.

Install OpenAPI Generator using Homebrew:

brew install openapi-generator

Generating TypeScript Client Code Using the OAS Definitions

v1

openapi-generator generate -i src/v1/spec.yaml -g typescript-axios -o src/v1/swagger-tmp

v2

openapi-generator generate -i src/v2/spec.yaml -g typescript-axios -o src/v2/swagger-tmp

hub-rest-api

openapi-generator generate -i src/hub-rest-api/spec.yaml -g typescript-axios -o src/hub-rest-api/swagger-tmp

For other languages, replace <generator> with a desired generator.