How to use @api-platform/api-doc-parser - 7 common examples

To help you get started, we’ve selected a few @api-platform/api-doc-parser 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 silverbackis / ComponentsWebApp / admin / src / App.js View on Github external
const apiDocumentationParser = (entrypoint) => parseHydraDocumentation(entrypoint, { headers: new Headers(fetchHeaders) })
  .then(
    ({ api }) => {
      api.resources = api.resources.filter(({ name }) => {
        return 'users' === name
      });
      return { api };
    },
    (result) => {
      switch (result.status) {
        case 401:
          return Promise.resolve({
            api: result.api,
            customRoutes: [{
              props: {
                path: '/',
                render: () => ,
github phpdocker-io / phpdocker.io / admin / src / App.js View on Github external
const myApiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoint)
    .then(({api}) => {
        const posts = api.resources.find(({name}) => 'posts' === name);
        const body  = posts.fields.find(f => 'body' === f.name);
        const bodyIntro  = posts.fields.find(f => 'bodyIntro' === f.name);

        body.input = props => (
            
        );

        bodyIntro.input = props => (
            
        );

        const defaultProps = {
            addField: true,
            addLabel: true
github api-platform / client-generator / src / index.js View on Github external
const parser = entrypointWithSlash => {
  const options = {};
  if (program.username && program.password) {
    const encoded = Buffer.from(
      `${program.username}:${program.password}`
    ).toString("base64");
    options.headers = new Headers();
    options.headers.set("Authorization", `Basic ${encoded}`);
  }
  switch (program.format) {
    case "swagger":
      return parseSwaggerDocumentation(entrypointWithSlash);
    case "openapi3":
      return parseOpenApi3Documentation(entrypointWithSlash);
    default:
      return parseHydraDocumentation(entrypointWithSlash, options);
  }
};
github api-platform / client-generator / src / index.js View on Github external
const parser = entrypointWithSlash => {
  const options = {};
  if (program.username && program.password) {
    const encoded = Buffer.from(
      `${program.username}:${program.password}`
    ).toString("base64");
    options.headers = new Headers();
    options.headers.set("Authorization", `Basic ${encoded}`);
  }
  switch (program.format) {
    case "swagger":
      return parseSwaggerDocumentation(entrypointWithSlash);
    case "openapi3":
      return parseOpenApi3Documentation(entrypointWithSlash);
    default:
      return parseHydraDocumentation(entrypointWithSlash, options);
  }
};
github api-platform / client-generator / src / index.js View on Github external
const parser = entrypointWithSlash => {
  const options = {};
  if (program.username && program.password) {
    const encoded = Buffer.from(
      `${program.username}:${program.password}`
    ).toString("base64");
    options.headers = new Headers();
    options.headers.set("Authorization", `Basic ${encoded}`);
  }
  switch (program.format) {
    case "swagger":
      return parseSwaggerDocumentation(entrypointWithSlash);
    case "openapi3":
      return parseOpenApi3Documentation(entrypointWithSlash);
    default:
      return parseHydraDocumentation(entrypointWithSlash, options);
  }
};
github api-platform / admin / src / hydra / fetchHydra.js View on Github external
export default (url, options = {}) => {
  const requestHeaders = options.headers || new Headers();

  if (options.user && options.user.authenticated && options.user.token) {
    requestHeaders.set('Authorization', options.user.token);
  }

  return fetchJsonLd(url, {
    ...options,
    headers: requestHeaders,
  }).then(data => {
    const status = data.response.status;

    if (status < 200 || status >= 300) {
      return promises
        .expand(data.body, {
          base: getDocumentationUrlFromHeaders(data.response.headers),
        })
        .then(json => {
          return Promise.reject(
            new HttpError(
              json[0]['http://www.w3.org/ns/hydra/core#description'][0][
                '@value'
              ],
github api-platform / admin / src / hydra / fetchHydra.js View on Github external
}).then(data => {
    const status = data.response.status;

    if (status < 200 || status >= 300) {
      return promises
        .expand(data.body, {
          base: getDocumentationUrlFromHeaders(data.response.headers),
        })
        .then(json => {
          return Promise.reject(
            new HttpError(
              json[0]['http://www.w3.org/ns/hydra/core#description'][0][
                '@value'
              ],
              status,
            ),
          );
        })
        .catch(e => {
          if (e.hasOwnProperty('body')) {
            return Promise.reject(e);
          }

@api-platform/api-doc-parser

Transform an API documentation (Hydra, OpenAPI, GraphQL) in an intermediate representation that can be used for various tasks such as creating smart API clients, scaffolding code or building administration interfaces.

MIT
Latest version published 21 days ago

Package Health Score

87 / 100
Full package analysis

Similar packages