Socket
Book a DemoInstallSign in
Socket

@thoughtspot/graph-to-openapi

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thoughtspot/graph-to-openapi

Get an OpenAPI 3.0 spec out of a graphql Schema

0.9.3
latest
Source
npmnpm
Version published
Weekly downloads
1.1K
59.31%
Maintainers
0
Weekly downloads
 
Created
Source

graph-to-openapi

Coverage Status npm (scoped) example branch parameter

Convert a Graphql Schema to OpenAPI Spec w/ customization hooks

Usage

# schema.graphql

## This directive declaration needs to be added to your graphql definitions.
## Needs to be defined only once.
directive @rest(
  """
  REST path for the generated API route.
  """
  path: String = "/api/" # Can specify a default value.
  """
  API Method
  """
  method: String = "GET"
  """
  Tag to add to the generated API route.
  """
  tag: String = ""
  """
  Hide the operation from the generated spec.
  """
  hidden: Boolean = false
) on FIELD_DEFINITION

type Mutation {
  """
  This is a comment which will become the description of this REST
  endpoint.
  """
  updateUser(
    """
    This comment becomes the description of the query parameter.
    """
    name: String
    """
    The GUID of the user account to query
    """
    id: String!

    """
    The updated display name
    """
    displayName: String
  ): UserResponse @rest(path: "/user", method: "PUT", tag: "User") # Define the openAPI spec config here.
}

type Query {
  getUser(
    """
    The GUID of the user account to query
    """
    id: String!
  ): UserResponse @rest(path: "/user", method: "GET", tag: "User")
}

type UserResponse {
  ...
}
import { getOpenAPISpec } from '@thoughtspot/gql-to-openapi';

const { spec } = getOpenAPISpec({
    schema,
    info: {},
    basePath: '/api/v1',
});

fs.writeFile(fileName, openAPISpec);

Keywords

graphql

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.