This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3 convert nested schemas into sequential schemas (#177)
* Writes nested schemas earlier and uses them later * Refactors order CodegenSchema properties are set in to match the order in getSchemas * Adjusts ref input to setSchemaLocationInfo * Tweak improves schema template * Adds properties classes * Replaces properties with field * Uses Schema_() * Uses dataclass properties * Adds missing type info * Updates all_of * Adds any_of, all_of tuples * Fixes types definition * Fixed test_any_type_schema tests * Fixes dataclass type setting issues * Fixes simple schema format type * Adds and uses PatternInfo for pattern schema info, validate_regex changed to validate_pattern * Fixes not constraint tests * Adds tuple_to_instance * Writes out allOf/anyOf/oneOf types * Updates classproperty decorator * Adds enum return types * Fixes type errors in schemas.py * Adds schema singleton metaclass * Replaces CodegenServer variables with object schema containing variables in properties * Generates server variables as an object schema to keep all schemas at the root depth * Fixes new signatures in servers schemas * Simplifies Server variables definition * Uses schema default for server variables * Adds required vars in server definition * Fixes classproperty and SchemaBase classes * Fixes broken configuration tests * Fixes server docs * Adds isInlineDefinition * Adds allOf/anyOf/oneOf/properties jsonPathPiece * Uses jsonPathPiece in properties/allOf/anyOf/oneOf * Fixes properties typeddict name * Templates updated to write allOf/anyOf/oneOf/properties earlier if possible * generates properties/allOf/anyOf/oneOf before class if possible * Adds and uses schemas.INPUT_TYPES_ALL_INCL_SCHEMA * Adds another usage of schemas.INPUT_TYPES_ALL_INCL_SCHEMA * Changes SchemaBase to SingletonMeta * Only calculates allSchemas once * Reduces iteration through allSchemas from 2x to 1x * Removes some getKey invocations * Consolidates more getKey usages * Deletes getKey with one input * Adds comment * Updates the definition of required properties, reduces the number of calls to getKey * Updates getKey to use sourceJsonPath * Adds class name generation that includes numbered suffixes when needed * Uses pre order traversal for naming schema classes * Fixes oneOf/anyOf/allOf type aliases * Adds and uses schemas.INPUT_BASE_TYPES * Adds string representation of CodegenKey * Fixes java tests * Samples regenerated * Samples regenerated
- Loading branch information
Showing
409 changed files
with
13,691 additions
and
18,415 deletions.
There are no files selected for viewing
This file contains 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
306 changes: 170 additions & 136 deletions
306
...son-schema-generator/src/main/java/org/openapijsonschematools/codegen/DefaultCodegen.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
26 changes: 26 additions & 0 deletions
26
...enerator/src/main/java/org/openapijsonschematools/codegen/model/ArrayListWithContext.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.openapijsonschematools.codegen.model; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* A class to store inline codegenschema definitions | ||
*/ | ||
public class ArrayListWithContext<E> extends ArrayList<E> implements InlineContext { | ||
private boolean internalallAreInline = false; | ||
private CodegenKey internalJsonPathPiece = null; | ||
public boolean allAreInline() { | ||
return internalallAreInline; | ||
} | ||
|
||
public void setAllAreInline(boolean allAreInline) { | ||
this.internalallAreInline = allAreInline; | ||
} | ||
|
||
public CodegenKey jsonPathPiece() { | ||
return internalJsonPathPiece; | ||
} | ||
|
||
public void setJsonPathPiece(CodegenKey jsonPathPiece) { | ||
this.internalJsonPathPiece = jsonPathPiece; | ||
} | ||
} |
This file contains 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 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 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
11 changes: 11 additions & 0 deletions
11
...chema-generator/src/main/java/org/openapijsonschematools/codegen/model/InlineContext.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.openapijsonschematools.codegen.model; | ||
|
||
public interface InlineContext { | ||
public boolean allAreInline(); | ||
|
||
public void setAllAreInline(boolean allAreInline); | ||
|
||
public CodegenKey jsonPathPiece(); | ||
|
||
public void setJsonPathPiece(CodegenKey jsonPathPiece); | ||
} |
23 changes: 23 additions & 0 deletions
23
...ator/src/main/java/org/openapijsonschematools/codegen/model/LinkedHashMapWithContext.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.openapijsonschematools.codegen.model; | ||
|
||
import java.util.LinkedHashMap; | ||
|
||
public class LinkedHashMapWithContext<K, V> extends LinkedHashMap<K, V> implements InlineContext { | ||
private boolean internalallAreInline = false; | ||
private CodegenKey internalJsonPathPiece = null; | ||
public boolean allAreInline() { | ||
return internalallAreInline; | ||
} | ||
|
||
public void setAllAreInline(boolean allAreInline) { | ||
this.internalallAreInline = allAreInline; | ||
} | ||
|
||
public CodegenKey jsonPathPiece() { | ||
return internalJsonPathPiece; | ||
} | ||
|
||
public void setJsonPathPiece(CodegenKey jsonPathPiece) { | ||
this.internalJsonPathPiece = jsonPathPiece; | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -14,4 +14,4 @@ None, | |
bytes, | ||
io.FileIO, | ||
io.BufferedReader, | ||
'Schema', | ||
'Schema', |
9 changes: 9 additions & 0 deletions
9
...json-schema-generator/src/main/resources/python/components/schemas/_helper_allof_type.hbs
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{allOf.jsonPathPiece.camelCase}} = typing.Tuple[ | ||
{{#each allOf}} | ||
{{#if refInfo.refClass}} | ||
typing.Type[{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}}], | ||
{{else}} | ||
typing.Type[{{jsonPathPiece.camelCase}}[schemas.U]], | ||
{{/if}} | ||
{{/each}} | ||
] |
9 changes: 9 additions & 0 deletions
9
...json-schema-generator/src/main/resources/python/components/schemas/_helper_anyof_type.hbs
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{anyOf.jsonPathPiece.camelCase}} = typing.Tuple[ | ||
{{#each anyOf}} | ||
{{#if refInfo.refClass}} | ||
typing.Type[{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}}], | ||
{{else}} | ||
typing.Type[{{jsonPathPiece.camelCase}}[schemas.U]], | ||
{{/if}} | ||
{{/each}} | ||
] |
Oops, something went wrong.