
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
schema-openapi
Advanced tools
Declarative pipe-able API for OpenAPI specification construction using @effect/schema.
:construction: Under development.
pnpm add schema-openapi
@effect/schemaThe heart of this library is a compiler that derives an OpenAPI schema
from an effect-ts Schema declaration. Generated schema can be adjusted
using annotations. Following annotations are supported:
DescriptionAnnotationJSONSchemaAnnotationPlease, consult the schema API documentation.
Top-level
Operations
General
import * as OpenApi from 'schema-openapi';
openAPIUse openAPI('Name of you API', 'version') to initialize a new
openAPI specification.
Available setters: info
infoSets info section of the specification.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.info(OpenApi.description('This is my awesome API'))
);
Available setters: description, license, server
Setter of: openAPI
licenseSets a license in the info section.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.info(
OpenApi.description('This is my awesome API'),
OpenApi.license('MIT', 'http://license-url')
)
);
Setter of: info
serverSets a server section.
OpenApi.openAPI('My API', '2.0.1', OpenApi.server('http://my-production.com'));
Available setters: description, variable
Setter of: openAPI
variableAdds a variable to the server section.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.server(
'http://my-production:{port}.com',
OpenApi.variable('port', '3000')
)
);
Available setters: description, enum
Setter of: server
enumAdds possible values of a server variable.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.server(
'http://my-production:{port}.com',
OpenApi.variable('port', '3000', OpenApi.enum('3000', '3001'))
)
);
Setter of: variable
pathAdd a new path.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.string, 'Returns a pet')
)
),
OpenApi.path(
'/note',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.string, 'Returns a note')
)
)
);
Available setters: description, operation
Setter of: openAPI
operationSet operation. Method name can be one of get, put, post, delete,
options, head, patch, trace.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.string, 'Returns a pet')
),
OpenApi.operation(
'post',
OpenApi.jsonRequest(S.struct({ value: S.number })),
OpenApi.jsonResponse('200', S.string, 'Returns a pet')
)
)
);
Available setters: description, parameter, jsonResponse, jsonRequest, deprecated, operationId
Setter of: path
parameterSet a parameter. The (second) in parameter is one of query, header,
path, cookie. If the in is path, required must be set
for the parameter.
Set the operation id using OpenApi.operationId.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.struct({ value: S.number }), 'Returns a pet')
OpenApi.parameter('id', 'path', S.number, OpenApi.required),
OpenApi.parameter('name', 'query', S.string),
OpenApi.operationId('getPet')
)
)
);
Setter of: operation
parameterSet a parameter. The (second) in parameter is one of query, header,
path, cookie. If the in is path, required must be set
for the parameter.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.struct({ value: S.number }), 'Returns a pet')
OpenApi.parameter('id', 'path', S.number, OpenApi.required),
OpenApi.parameter('name', 'query', S.string),
)
)
);
Available setters: required, description, deprecated, allowEmptyValue
Setter of: operation
tagsSet tags for an operation.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.struct({ value: S.number }), 'Returns a pet')
OpenApi.parameter('id', 'path', S.number, OpenApi.required),
OpenApi.parameter('name', 'query', S.string),
OpenApi.tags('Pets')
)
)
);
Setter of: operation
allowEmptyValueConfigures the parameter.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'get',
OpenApi.jsonResponse('200', S.struct({ value: S.number }), 'Returns a pet')
OpenApi.parameter('id', 'path', S.number, OpenApi.required),
OpenApi.parameter('name', 'query', S.string, OpenApi.allowEmptyValue),
)
)
);
Setter of: parameter
jsonRequestSet the JSON request body specification.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'post',
OpenApi.jsonResponse(
'200',
S.struct({ value: S.number }),
'Returns a pet'
),
OpenApi.jsonRequest(S.struct({ value: S.number }))
)
)
);
Available setters: description, required
Setter of: operation
jsonResponseSet the JSON response specification. The (2nd) schema parameter can be
either undefined or Schema<R, I, O>. If it's set to undefined, the
content field of the response is ommited.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'post',
OpenApi.jsonResponse(
'200',
S.struct({ value: S.number }),
'Returns a pet'
)
)
)
);
Available setters: description, responseHeaders
Setter of: operation
responseHeadersSet the response headers.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'post',
OpenApi.jsonResponse(
'200',
S.struct({ value: S.number }),
'Returns a pet',
OpenApi.responseHeaders({ 'My-Header': S.string })
)
)
)
);
Setter of: jsonResponse
descriptionSets a description field.
Setter of: info, operation, parameter
summarySets a summary field.
deprecatedSets the spec as deprecated.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'get',
OpenApi.jsonResponse(
'200',
S.struct({ value: S.number }),
'Returns a pet'
),
OpenApi.parameter('name', 'query', S.string, OpenApi.deprecated),
OpenApi.deprecated
),
OpenApi.deprecated
)
);
Setter of: parameter, operation, parameter
requiredSets the parameter as required.
OpenApi.openAPI(
'My API',
'2.0.1',
OpenApi.path(
'/pet/{id}',
OpenApi.operation(
'post',
OpenApi.jsonRequest(S.struct({ value: S.number }), OpenApi.required),
OpenApi.jsonResponse(
'201',
S.struct({ value: S.literal('success') }),
'Returns a pet'
),
OpenApi.parameter('name', 'path', S.string, OpenApi.required)
)
)
);
Setter of: parameter, jsonRequest
FAQs
Pipeable API for OpenAPI specification and @effect/schema compilers
The npm package schema-openapi receives a total of 56 weekly downloads. As such, schema-openapi popularity was classified as not popular.
We found that schema-openapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.