Home / File/ tutorial004.js — fastapi Source File

tutorial004.js — fastapi Source File

Architecture documentation for tutorial004.js, a javascript file in the fastapi codebase. 1 imports, 0 dependents.

File javascript FastAPI Responses 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  891af034_f4cd_0a7e_9550_f336b6490fb5["tutorial004.js"]
  b7fc865c_af80_f8f9_bc83_45687f1abfd2["fs"]
  891af034_f4cd_0a7e_9550_f336b6490fb5 --> b7fc865c_af80_f8f9_bc83_45687f1abfd2
  style 891af034_f4cd_0a7e_9550_f336b6490fb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as fs from 'fs'

async function modifyOpenAPIFile(filePath) {
  try {
    const data = await fs.promises.readFile(filePath)
    const openapiContent = JSON.parse(data)

    const paths = openapiContent.paths
    for (const pathKey of Object.keys(paths)) {
      const pathData = paths[pathKey]
      for (const method of Object.keys(pathData)) {
        const operation = pathData[method]
        if (operation.tags && operation.tags.length > 0) {
          const tag = operation.tags[0]
          const operationId = operation.operationId
          const toRemove = `${tag}-`
          if (operationId.startsWith(toRemove)) {
            const newOperationId = operationId.substring(toRemove.length)
            operation.operationId = newOperationId
          }
        }
      }
    }

    await fs.promises.writeFile(
      filePath,
      JSON.stringify(openapiContent, null, 2),
    )
    console.log('File successfully modified')
  } catch (err) {
    console.error('Error:', err)
  }
}

const filePath = './openapi.json'
modifyOpenAPIFile(filePath)

Domain

Subdomains

Dependencies

  • fs

Frequently Asked Questions

What does tutorial004.js do?
tutorial004.js is a source file in the fastapi codebase, written in javascript. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in tutorial004.js?
tutorial004.js defines 1 function(s): modifyOpenAPIFile.
What does tutorial004.js depend on?
tutorial004.js imports 1 module(s): fs.
Where is tutorial004.js in the architecture?
tutorial004.js is located at docs_src/generate_clients/tutorial004.js (domain: FastAPI, subdomain: Responses, directory: docs_src/generate_clients).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free