Skip to content

Commit

Permalink
Env variables to customize the openapi filename
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Jan 15, 2025
1 parent 03283c4 commit 360d334
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ pip install atom-tools
atom usages --extract-endpoints -o app.atom --slice-outfile usages.json -l java .
```

A file called `openapi.generated.json` would be created with the endpoints information.
A file called `openapi.generated.json` would be created with the endpoints information. Use the environment variable `ATOM_TOOLS_OPENAPI_FILENAME` to customize the filename.

```shell
ATOM_TOOLS_OPENAPI_FILENAME=openapi.json atom usages --extract-endpoints -o app.atom --slice-outfile usages.json -l ruby .
```

### Export atom to graphml or dot format

Expand Down
9 changes: 6 additions & 3 deletions src/main/scala/io/appthreat/atom/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,17 @@ object Atom:
case u: UsagesConfig =>
saveSlice(config.outputSliceFile, sliceCpg(ag).map(_.toJson))
if u.extractEndpoints then
val openapiFileName =
sys.env.getOrElse("ATOM_TOOLS_OPENAPI_FILENAME", "openapi.generated.json")
val openapiFormat = sys.env.getOrElse("ATOM_TOOLS_OPENAPI_FORMAT", "openapi3.1.0")
val result = ExternalCommand.run(
s"atom-tools convert -i ${config.outputSliceFile} -t ${config.language} -f openapi3.1.0 -q -o ${config
.inputPath.pathAsString}${java.io.File.separator}openapi.generated.json",
s"atom-tools convert -i ${config.outputSliceFile} -t ${config.language} -f ${openapiFormat} -q -o ${config
.inputPath.pathAsString}${java.io.File.separator}${openapiFileName}",
"."
)
result match
case Success(_) =>
println("openapi.generated.json created successfully.")
println(s"${openapiFileName} created successfully.")
case Failure(exception) =>
println(
s"Failed to run atom-tools. Use the atom container image or perform 'pip install atom-tools' and re-run this command. Exception: ${exception.getMessage}"
Expand Down

0 comments on commit 360d334

Please sign in to comment.