0.9.0 • Published 4 months ago

@thoughtspot/graph-to-openapi v0.9.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
4 months ago

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);
0.9.0

4 months ago

0.8.4

11 months ago

0.8.1

12 months ago

0.8.2

12 months ago

0.7.6

1 year ago

0.7.7

1 year ago

0.8.0

1 year ago

0.7.5

1 year ago

0.7.2

1 year ago

0.6.3

2 years ago

0.7.1

1 year ago

0.6.2

2 years ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago