mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +00:00
Add process utils class to add index to properties (#1796)
* add process utils to add index to properties * fix javadoc warning
This commit is contained in:
@@ -29,6 +29,7 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -425,6 +426,16 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
// add x-index to properties
|
||||
ProcessUtils.addIndexToProperties(models);
|
||||
return objs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.openapitools.codegen.utils;
|
||||
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProcessUtils {
|
||||
|
||||
/**
|
||||
* Add x-index extension to the model's properties
|
||||
*
|
||||
* @param models List of models
|
||||
*/
|
||||
public static void addIndexToProperties(List<Object> models) {
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
int i = 0;
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
var.vendorExtensions.put("x-index", i);
|
||||
i++;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
var.vendorExtensions.put("x-index", j);
|
||||
j++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ function New-{{{classname}}} {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
{{#vars}}
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true{{#required}}, Mandatory = $true{{/required}})]
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipelineByPropertyName = $true{{#required}}, Mandatory = $true{{/required}})]
|
||||
[{{#isString}}{{{dataType}}}{{/isString}}{{^isString}}{{^required}}System.Nullable[{{/required}}{{dataType}}{{^required}}]{{/required}}{{/isString}}]
|
||||
{{=<% %>=}}
|
||||
${<%name%>}<%^-last%>,<%/-last%>
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
||||
@@ -3,7 +3,7 @@ function Invoke-PetApiAddPet {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Pet]
|
||||
${pet}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -11,7 +11,7 @@ function Invoke-PetApiAddPet {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.AddPet(
|
||||
${pet}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ function Invoke-PetApiUpdatePet {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Pet]
|
||||
${pet}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -105,7 +105,7 @@ function Invoke-PetApiUpdatePet {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.UpdatePet(
|
||||
${pet}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ function Invoke-StoreApiPlaceOrder {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Order]
|
||||
${order}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -61,7 +61,7 @@ function Invoke-StoreApiPlaceOrder {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:StoreApi.PlaceOrder(
|
||||
${order}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ function Invoke-UserApiCreateUser {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User]
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -11,7 +11,7 @@ function Invoke-UserApiCreateUser {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUser(
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ function Invoke-UserApiCreateUsersWithArrayInput {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User[]]
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -29,7 +29,7 @@ function Invoke-UserApiCreateUsersWithArrayInput {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUsersWithArrayInput(
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ function Invoke-UserApiCreateUsersWithListInput {
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User[]]
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -47,7 +47,7 @@ function Invoke-UserApiCreateUsersWithListInput {
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUsersWithListInput(
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function Invoke-UserApiUpdateUser {
|
||||
${username},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User]
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
@@ -141,7 +141,7 @@ function Invoke-UserApiUpdateUser {
|
||||
|
||||
$Script:UserApi.UpdateUser(
|
||||
${username},
|
||||
${user}
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ function New-ApiResponse {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${code},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${type},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${message}
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ function New-Category {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${name}
|
||||
)
|
||||
|
||||
@@ -4,19 +4,19 @@ function New-Order {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${petId},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${quantity},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[System.DateTime]]
|
||||
${shipDate},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${status},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Boolean]]
|
||||
${complete}
|
||||
)
|
||||
|
||||
@@ -4,19 +4,19 @@ function New-Pet {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Org.OpenAPITools.Model.Category]]
|
||||
${category},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${name},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String[]]
|
||||
${photoUrls},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Org.OpenAPITools.Model.Tag[]]]
|
||||
${tags},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${status}
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ function New-Tag {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${name}
|
||||
)
|
||||
|
||||
@@ -4,25 +4,25 @@ function New-User {
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${username},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${firstName},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${lastName},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${email},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${password},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${phone},
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${userStatus}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user