Skip to content

Commit

Permalink
Remove superfluous oneOfs
Browse files Browse the repository at this point in the history
  • Loading branch information
elsand committed Sep 15, 2024
1 parent fccc985 commit ede7f36
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/extract_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ openapi2jsonschema --clean --output "$FINAL_SCHEMA_DIR" --input "$BUNDLED_OPENAP
echo "Converted JSON Schema files saved to $FINAL_SCHEMA_DIR."

# Step 5: Find the specific schema file for the specified component
find . -name "*$TARGET_FILE" -exec mv {} $FINAL_SCHEMA_FILE.tmp \;
find . -name "*$TARGET_FILE" -exec mv {} $FINAL_SCHEMA_FILE \;

# Step 6: Remove superfluous oneOfs
jq 'walk(if type == "object" and .oneOf then
if (.oneOf | length) == 1 then
.oneOf[0]
else
.
end
else
.
end)' $FINAL_SCHEMA_FILE > $FINAL_SCHEMA_FILE.tmp

echo "Schema '$SCHEMA_NAME' extracted and saved to $FINAL_SCHEMA_FILE."

Expand Down

0 comments on commit ede7f36

Please sign in to comment.