How to use the @stoplight/prism-http.getHttpOperationsFromResource function in @stoplight/prism-http

To help you get started, we’ve selected a few @stoplight/prism-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / prism / packages / http-server / src / __tests__ / server.oas.spec.ts View on Github external
async function instantiatePrism(specPath: string) {
  const operations = await getHttpOperationsFromResource(specPath);
  return createServer(operations, {
    components: { logger },
    config: {
      checkSecurity: true,
      validateRequest: true,
      validateResponse: true,
      mock: { dynamic: false },
    },
    errors: false,
    cors: true,
  });
}
github stoplightio / prism / packages / cli / src / util / runner.ts View on Github external
watcher.on('change', () => {
        server.fastify.log.info('Restarting Prism...');

        getHttpOperationsFromResource(options.document)
          .then(operations => {
            if (operations.length === 0) {
              server.fastify.log.info(
                'No operations found in the current file, continuing with the previously loaded spec.'
              );
            } else {
              return server.fastify
                .close()
                .then(() => {
                  server.fastify.log.info('Loading the updated operations...');

                  return createPrism(options);
                })
                .then(newServer => {
                  if (newServer) {
                    server = newServer;
github stoplightio / prism / packages / cli / src / util / createServer.ts View on Github external
async function createPrismServerWithLogger(options: CreateBaseServerOptions, logInstance: Logger) {
  const operations = await getHttpOperationsFromResource(options.document);

  if (operations.length === 0) {
    throw new Error('No operations found in the current file.');
  }

  const shared: Omit = {
    validateRequest: true,
    validateResponse: true,
    checkSecurity: true,
    errors: false,
  };

  const config: IHttpProxyConfig | IHttpConfig = isProxyServerOptions(options)
    ? { ...shared, mock: false, upstream: options.upstream }
    : { ...shared, mock: { dynamic: options.dynamic } };