-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Stream example rendering to avoid OOM for large specs #24160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wilx
wants to merge
42
commits into
OpenAPITools:master
Choose a base branch
from
wilx:issue-23849
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122,542
−2,173
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
8692092
Stream mustache example lambdas
wilx 7d86dc3
Add Spring regression test for issue 23849
wilx 71c8a12
Fix OOM by streaming generated examples and specs
wilx 9819ca8
Fix JetBrains HTTP client inline examples
wilx 7651ac2
SpringCodegenTest: Disable OOM test for now.
wilx 20d50b2
Fix streaming example rendering
wilx 260d7fb
Use example lambda in remaining templates
wilx 85d73f9
Regenerate index.html.
wilx e53384d
Refine JetBrains HTTP request examples
wilx cd1861e
Fix blank lines.
wilx 9e6fcf2
Escape streamed examples in annotations
wilx fbea63f
Escape streamed examples in Postman JSON
wilx c300777
Write streamed templates atomically
wilx 79dc323
Guard C# Functions doc examples
wilx 51b5a40
Include JSON examples in parameter equality
wilx aeaa7d2
Stream Kotlin Spring line break removal lambda
wilx 2365226
Stream Kotlin Spring string escape lambda
wilx 1319521
Escape GraphQL resolver examples
wilx 9fd6442
Escape C# Functions controller examples
wilx 387d899
Escape ASP.NET Core controller examples
wilx ba55b0c
Preserve F# Giraffe streamed examples
wilx 3bedd19
Avoid repeated prefix deletion in unique lambda
wilx 342df06
Compare minimal-update files with Commons IO
wilx f8d3344
Use unique temp files for template writes
wilx ddc8245
Stream HTML escaping lambda output
wilx 341142e
Escape static HTML response examples
wilx 00d3a48
Avoid extra Postman partial newline
wilx 0174836
Avoid hashing JSON parameter examples
wilx 3cc33b2
Update modules/openapi-generator/src/main/java/org/openapitools/codeg…
wilx fd590a6
Include JSON examples in property equality
wilx cef95b7
Render GraphQL examples as typed literals
wilx b516bf6
Escape F# Giraffe example string literals
wilx 29170d5
Use parameter example setter in generators
wilx edb018d
Fix HTML escape lambda usage docs
wilx 45192b1
Document HTML escape lambda context
wilx f7a8c49
Preserve scalar example rendering
wilx 39145da
Make JSON output tests line-ending neutral
wilx c812434
Pin Rust Axum time dependency below 0.3.52
wilx 41551f2
Pin Rust Salvo time dependency below 0.3.52
wilx 4abf208
Document streaming example template rendering
wilx 3a9e23b
Remove stale C# Functions example fallback
wilx 815295e
Revert "SpringCodegenTest: Disable OOM test for now."
wilx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,14 @@ | |
|
|
||
| package org.openapitools.codegen; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.samskivert.mustache.Mustache; | ||
| import io.swagger.v3.oas.models.examples.Example; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
| import org.openapitools.codegen.templating.mustache.JsonOutputLambda; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.*; | ||
|
|
||
| /** | ||
|
|
@@ -41,6 +45,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties { | |
| public String nameInPascalCase; // property name in pascal case (e.g. ModifiedDate) | ||
| public String nameInSnakeCase; // property name in upper snake case | ||
| public String example; // example value (x-example) | ||
| private JsonNode exampleJsonNode; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: New private Prompt for AI agents |
||
| public Map<String, Example> examples; | ||
| public String jsonSchema; | ||
| public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, | ||
|
|
@@ -184,6 +189,7 @@ public CodegenParameter copy() { | |
| output.defaultValue = this.defaultValue; | ||
| output.enumDefaultValue = this.enumDefaultValue; | ||
| output.example = this.example; | ||
| output.exampleJsonNode = this.exampleJsonNode; | ||
| output.examples = this.examples; | ||
| output.isEnum = this.isEnum; | ||
| output.isEnumRef = this.isEnumRef; | ||
|
|
@@ -392,6 +398,7 @@ public boolean equals(Object o) { | |
| Objects.equals(isMatrix, that.isMatrix) && | ||
| Objects.equals(isAllowEmptyValue, that.isAllowEmptyValue) && | ||
| Objects.equals(example, that.example) && | ||
| Objects.equals(exampleJsonNode, that.exampleJsonNode) && | ||
| Objects.equals(examples, that.examples) && | ||
| Objects.equals(jsonSchema, that.jsonSchema) && | ||
| Objects.equals(_enum, that._enum) && | ||
|
|
@@ -543,6 +550,53 @@ public Map<String, Object> getExts() { | |
| return vendorExtensions; | ||
| } | ||
|
|
||
| public Mustache.Lambda getLambdaExample() { | ||
| if (exampleJsonNode != null) { | ||
| if (exampleJsonNode.isValueNode()) { | ||
| return new JsonOutputLambda(exampleJsonNode.asText()); | ||
| } | ||
| return new JsonOutputLambda(exampleJsonNode); | ||
| } | ||
| if (example != null) { | ||
| return new JsonOutputLambda(example); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public Mustache.Lambda getLambdaExampleJsonLiteral() { | ||
| if (exampleJsonNode != null) { | ||
| return new JsonOutputLambda(exampleJsonNode); | ||
| } | ||
| if (example == null) { | ||
| return null; | ||
| } | ||
| if (isBoolean) { | ||
| return new JsonOutputLambda(Boolean.valueOf(example)); | ||
| } | ||
| if (isNumeric || isInteger || isLong || isNumber || isFloat || isDouble || isDecimal || isShort || isUnboundedInteger) { | ||
| try { | ||
| return new JsonOutputLambda(new BigDecimal(example)); | ||
| } catch (NumberFormatException e) { | ||
| return new JsonOutputLambda((Object) example); | ||
| } | ||
| } | ||
| return new JsonOutputLambda((Object) example); | ||
| } | ||
|
|
||
| public boolean getHasExample() { | ||
| return exampleJsonNode != null || example != null; | ||
| } | ||
|
|
||
| public void setExample(String example) { | ||
| this.example = example; | ||
| this.exampleJsonNode = null; | ||
| } | ||
|
|
||
| public void setExample(JsonNode exampleJsonNode) { | ||
| this.exampleJsonNode = exampleJsonNode; | ||
| this.example = exampleJsonNode != null && exampleJsonNode.isValueNode() ? exampleJsonNode.asText() : null; | ||
| } | ||
|
|
||
| // use schema.getContains or content.mediaType.schema.getContains instead of this | ||
| @Override | ||
| public CodegenProperty getContains() { | ||
|
|
@@ -1151,4 +1205,3 @@ public void setIsEnum(boolean isEnum) { | |
| this.isEnum = isEnum; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.