forked from loafle/openapi-generator-original
* Improvement of Ada client and server generator - recognize several mime types and configure the client/server API - fix support to handle binary and ByteArray - add support for client and server with multiple mime type responses - update model templates * Fix and improvement of Ada code generator - fix order of model types to emit the types that depend on other types after; also sort the model types on their name - fix model Serialize to avoid serializing a field which is Null when it is not "Nullable" * Add support to avoid some Ada Vectors package instantiation - recognized the x-ada-no-vector specific attribute on model types and when present and TRUE, don't emit the Ada Vector package instantiation nor the Serialize and Deserialize associated procedures. * Fix float and double support - fix mapping for float and double - add x-ada-serialize-op custom attribute to allow overriding the serialize procedure - setup a default x-ada-serialize-op value for the template * Fix wrong import and serialize method * Regenerate the Ada client sample petstore * Rebuild with export_docs_generators.sh * Fix calls to toLowerCase() to use the Locale.ROOT
This commit is contained in:
parent
6299af176d
commit
b107ff96ac
@ -186,7 +186,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Readme|✗|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
@ -214,11 +214,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Header|✗|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✓|OAS3
|
||||
|Cookie|✗|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
@ -238,11 +238,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|BasicAuth|✗|OAS2,OAS3
|
||||
|ApiKey|✗|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✗|OAS3
|
||||
|OAuth2_Implicit|✗|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✓|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✓|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✓|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
|
@ -22,10 +22,10 @@ import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
@ -42,27 +42,77 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(AbstractAdaCodegen.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAdaCodegen.class);
|
||||
|
||||
public static final String HTTP_SUPPORT_OPTION = "httpSupport";
|
||||
public static final String OPENAPI_PACKAGE_NAME_OPTION = "openApiName";
|
||||
|
||||
// Common media types.
|
||||
private static final String APPLICATION_XML = "application/xml";
|
||||
private static final String TEXT_XML = "text/xml";
|
||||
private static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
|
||||
private static final String TEXT_PLAIN = "text/plain";
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
private static final String APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||
|
||||
// RFC 7807 Support
|
||||
private static final String APPLICATION_PROBLEM_JSON = "application/problem+json";
|
||||
private static final String APPLICATION_PROBLEM_XML = "application/problem+xml";
|
||||
|
||||
// RFC 7386 support
|
||||
private static final String APPLICATION_MERGE_PATCH_JSON = "application/merge-patch+json";
|
||||
|
||||
// Extension attributes used by the Ada code generator
|
||||
// "x-ada-type-name" allows to override the name generated for a type/object.
|
||||
// It can be a full qualified Ada type name and the type can be defined in an external package.
|
||||
// In that case, we don't generate the Ada type but use its external definition. Only the
|
||||
// Serialize/Deserialize are generated in the model. If there is an inconsistency, this will
|
||||
// be detected at compilation time.
|
||||
// "x-ada-no-vector" instructs to not instantiate the Vectors package for the given model type.
|
||||
// "x-ada-serialize-op" allows to control the name of the serialize operation for the field.
|
||||
private static final String X_ADA_TYPE_NAME = "x-ada-type-name";
|
||||
private static final String X_ADA_VECTOR_TYPE_NAME = "x-ada-vector-type-name";
|
||||
private static final String X_ADA_NO_VECTOR = "x-ada-no-vector";
|
||||
private static final String X_ADA_SERIALIZE_OP = "x-ada-serialize-op";
|
||||
|
||||
protected String packageName = "defaultPackage";
|
||||
protected String projectName = "defaultProject";
|
||||
protected List<ModelMap> orderedModels;
|
||||
protected final Map<String, List<String>> modelDepends;
|
||||
protected final Map<String, String> nullableTypeMapping;
|
||||
protected final Map<String, String> operationsScopes;
|
||||
protected final List<List<String>> mediaGroups;
|
||||
protected final List<List<NameBinding>> mediaLists;
|
||||
protected final Map<String, String> mediaToVariableName;
|
||||
protected final List<NameBinding> mediaVariables;
|
||||
protected final List<NameBinding> adaImports;
|
||||
protected final Set<String> adaImportSet = new TreeSet<>();
|
||||
protected int scopeIndex = 0;
|
||||
protected String httpClientPackageName = "Curl";
|
||||
protected String openApiPackageName = "Swagger";
|
||||
|
||||
private static final String bytesType = "swagger::ByteArray";
|
||||
|
||||
static class NameBinding {
|
||||
public int position;
|
||||
public String name;
|
||||
public String value;
|
||||
|
||||
NameBinding(int pos, String name, String value) {
|
||||
this.position = pos;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAdaCodegen() {
|
||||
super();
|
||||
|
||||
@ -169,12 +219,20 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
typeMapping.put("integer", "Integer");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
|
||||
typeMapping.put("binary", bytesType);
|
||||
typeMapping.put("ByteArray", bytesType);
|
||||
|
||||
// Mapping to convert an Ada required type to an optional type (nullable).
|
||||
nullableTypeMapping = new HashMap<>();
|
||||
|
||||
modelDepends = new HashMap<>();
|
||||
orderedModels = new ArrayList<>();
|
||||
operationsScopes = new HashMap<>();
|
||||
mediaGroups = new ArrayList<>();
|
||||
mediaLists = new ArrayList<>();
|
||||
mediaToVariableName = new HashMap<>();
|
||||
mediaVariables = new ArrayList<>();
|
||||
adaImports = new ArrayList<>();
|
||||
super.importMapping = new HashMap<>();
|
||||
|
||||
// CLI options
|
||||
@ -221,8 +279,11 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
typeMapping.put("number", openApiPackageName + ".Number");
|
||||
typeMapping.put("UUID", openApiPackageName + ".UString");
|
||||
typeMapping.put("URI", openApiPackageName + ".UString");
|
||||
typeMapping.put("file", openApiPackageName + ".Http_Content_Type");
|
||||
typeMapping.put("binary", openApiPackageName + ".Binary");
|
||||
typeMapping.put("file", openApiPackageName + ".Blob_Ref");
|
||||
typeMapping.put("binary", openApiPackageName + ".Blob_Ref");
|
||||
typeMapping.put("float", openApiPackageName + ".Number");
|
||||
typeMapping.put("double", openApiPackageName + ".Number");
|
||||
importMapping.put("File", openApiPackageName + ".File");
|
||||
|
||||
// Mapping to convert an Ada required type to an optional type (nullable).
|
||||
nullableTypeMapping.put(openApiPackageName + ".Date", openApiPackageName + ".Nullable_Date");
|
||||
@ -233,6 +294,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
nullableTypeMapping.put("Boolean", openApiPackageName + ".Nullable_Boolean");
|
||||
nullableTypeMapping.put(openApiPackageName + ".Object", openApiPackageName + ".Object");
|
||||
|
||||
mediaToVariableName.put(TEXT_PLAIN, openApiPackageName + ".Mime_Text");
|
||||
mediaToVariableName.put(APPLICATION_JSON, openApiPackageName + ".Mime_Json");
|
||||
mediaToVariableName.put(APPLICATION_XML, openApiPackageName + ".Mime_Xml");
|
||||
mediaToVariableName.put(APPLICATION_X_WWW_FORM_URLENCODED, openApiPackageName + ".Mime_Form");
|
||||
}
|
||||
|
||||
public String toFilename(String name) {
|
||||
@ -353,7 +418,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
String var = null;
|
||||
String var;
|
||||
if (value.isEmpty()) {
|
||||
var = "EMPTY";
|
||||
}
|
||||
@ -385,6 +450,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return var;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public CodegenProperty fromProperty(String name, Schema p, boolean required) {
|
||||
CodegenProperty property = super.fromProperty(name, p, required);
|
||||
@ -442,6 +508,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
* @return a string value used as the `dataType` field for model templates,
|
||||
* `returnType` for api templates
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
String schemaType = getSchemaType(p);
|
||||
@ -453,7 +520,12 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "_Vectors.Vector";
|
||||
String itemType = getTypeDeclaration(inner);
|
||||
if (itemType.startsWith("OpenAPI.")) {
|
||||
return itemType + "_Vector";
|
||||
} else {
|
||||
return itemType + "_Vectors.Vector";
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
@ -480,44 +552,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return modelPackage + ".Models." + modelType;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenProperty parameter) {
|
||||
boolean isStreamType = parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
|
||||
return isStreamType;
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenProperty parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenParameter parameter) {
|
||||
boolean isStreamType = parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
|
||||
return isStreamType;
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenParameter parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides postProcessParameter to add a vendor extension "x-is-model-type".
|
||||
* This boolean indicates that the parameter comes from the model package.
|
||||
@ -536,47 +570,10 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
parameter.vendorExtensions.put("x-is-stream-type", isStreamType(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process the media types (produces and consumes) for Ada code generator.
|
||||
* <p>
|
||||
* For each media type, add an adaMediaType member that gives the Ada enum constant
|
||||
* for the corresponding type.
|
||||
*
|
||||
* @param types the list of media types.
|
||||
* @return the number of media types.
|
||||
*/
|
||||
protected int postProcessMediaTypes(List<Map<String, String>> types) {
|
||||
int count = 0;
|
||||
if (types != null) {
|
||||
for (Map<String, String> media : types) {
|
||||
String mt = media.get("mediaType");
|
||||
if (mt != null) {
|
||||
mt = mt.replace('/', '_');
|
||||
media.put("adaMediaType", mt.toUpperCase(Locale.ROOT));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||
|
||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
|
||||
if (methodResponse != null && ModelUtils.getSchemaFromResponse(methodResponse) != null) {
|
||||
CodegenProperty cm = fromProperty("response", ModelUtils.getSchemaFromResponse(methodResponse), false);
|
||||
op.vendorExtensions.put("x-codegen-response", cm);
|
||||
op.vendorExtensions.put("x-is-model-type", isModelType(cm));
|
||||
op.vendorExtensions.put("x-is-stream-type", isStreamType(cm));
|
||||
if ("HttpContent".equals(cm.dataType)) {
|
||||
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a vendor extension attribute that provides a map of auth methods and the scopes
|
||||
// which are expected by the operation. This map is then used by postProcessOperationsWithModels
|
||||
// to build another vendor extension that provides a subset of the auth methods with only
|
||||
@ -592,96 +589,262 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
op.vendorExtensions.put("x-scopes", scopes);
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getAuthScopes(List<SecurityRequirement> securities, Map<String, SecurityScheme> securitySchemes) {
|
||||
final Map<String, List<String>> scopes = new HashMap<>();
|
||||
Optional.ofNullable(securitySchemes).ifPresent(_securitySchemes -> {
|
||||
for (SecurityRequirement requirement : securities) {
|
||||
for (String key : requirement.keySet()) {
|
||||
Optional.ofNullable(securitySchemes.get(key))
|
||||
.ifPresent(securityScheme -> scopes.put(key, requirement.get(key)));
|
||||
// Determine the types that this operation produces. `getProducesInfo`
|
||||
// simply lists all the types, and then we collect the list of media types
|
||||
// for the operation and keep the global index assigned to that list in x-produces-media-index.
|
||||
Set<String> produces = getProducesInfo(openAPI, operation);
|
||||
boolean producesPlainText = false;
|
||||
if (produces != null && !produces.isEmpty()) {
|
||||
List<String> mediaList = new ArrayList<>();
|
||||
List<Map<String, String>> c = new ArrayList<>();
|
||||
for (String mimeType : produces) {
|
||||
Map<String, String> mediaType = new HashMap<>();
|
||||
|
||||
if (isMimetypePlain(mimeType)) {
|
||||
producesPlainText = true;
|
||||
}
|
||||
|
||||
mediaType.put("mediaType", mimeType);
|
||||
c.add(mediaType);
|
||||
mediaList.add(mimeType);
|
||||
}
|
||||
op.produces = c;
|
||||
op.hasProduces = true;
|
||||
op.vendorExtensions.put("x-produces-media-index", collectMediaList(mediaList));
|
||||
}
|
||||
|
||||
for (CodegenResponse rsp : op.responses) {
|
||||
|
||||
if (rsp.dataType != null) {
|
||||
|
||||
// Write out the type of data we actually expect this response
|
||||
// to make.
|
||||
if (producesPlainText) {
|
||||
// Plain text means that there is not structured data in
|
||||
// this response. So it'll either be a UTF-8 encoded string
|
||||
// 'plainText' or some generic 'bytes'.
|
||||
//
|
||||
// Note that we don't yet distinguish between string/binary
|
||||
// and string/bytes - that is we don't auto-detect whether
|
||||
// base64 encoding should be done. They both look like
|
||||
// 'producesBytes'.
|
||||
if (bytesType.equals(rsp.dataType)) {
|
||||
rsp.vendorExtensions.put("x-produces-bytes", true);
|
||||
} else {
|
||||
rsp.vendorExtensions.put("x-produces-plain-text", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return scopes;
|
||||
for (CodegenProperty header : rsp.headers) {
|
||||
header.nameInCamelCase = toModelName(header.baseName);
|
||||
header.nameInLowerCase = header.baseName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// This is run after the postProcessModels
|
||||
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op1 : operationList) {
|
||||
if (op1.summary != null) {
|
||||
op1.summary = op1.summary.trim();
|
||||
}
|
||||
if (op1.notes != null) {
|
||||
op1.notes = op1.notes.trim();
|
||||
}
|
||||
op1.vendorExtensions.put("x-has-uniq-produces", postProcessMediaTypes(op1.produces) == 1);
|
||||
op1.vendorExtensions.put("x-has-uniq-consumes", postProcessMediaTypes(op1.consumes) == 1);
|
||||
op1.vendorExtensions.put("x-has-notes", op1.notes != null && op1.notes.length() > 0);
|
||||
for (CodegenOperation op : operationList) {
|
||||
postProcessOperationWithModels(op, allModels);
|
||||
}
|
||||
|
||||
// Set the file parameter type for both allParams and formParams.
|
||||
for (CodegenParameter p : op1.allParams) {
|
||||
if (p.isFormParam && p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
// Convert optional parameters to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
// Build the adaImports variable to create a list of Ada specific packages that must be imported.
|
||||
adaImportSet.remove(openApiPackageName);
|
||||
for (String adaImport : adaImportSet) {
|
||||
adaImports.add(new NameBinding(0, adaImport, adaImport));
|
||||
}
|
||||
additionalProperties.put("adaImports", adaImports);
|
||||
|
||||
// Add the media list variables.
|
||||
additionalProperties.put("mediaVariables", mediaVariables);
|
||||
additionalProperties.put("mediaLists", mediaLists);
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
private void postProcessOperationWithModels(CodegenOperation op, List<ModelMap> allModels) {
|
||||
|
||||
if (op.consumes != null) {
|
||||
List<String> mediaList = new ArrayList<>();
|
||||
for (Map<String, String> consume : op.consumes) {
|
||||
String mediaType = consume.get("mediaType");
|
||||
if (mediaType != null) {
|
||||
mediaList.add(mediaType.toLowerCase(Locale.ROOT));
|
||||
if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
||||
additionalProperties.put("usesUrlEncodedForm", true);
|
||||
} else if (isMimetypeMultipartFormData(mediaType)) {
|
||||
op.vendorExtensions.put("x-consumes-multipart", true);
|
||||
additionalProperties.put("apiUsesMultipartFormData", true);
|
||||
additionalProperties.put("apiUsesMultipart", true);
|
||||
} else if (isMimetypeMultipartRelated(mediaType)) {
|
||||
op.vendorExtensions.put("x-consumes-multipart-related", true);
|
||||
additionalProperties.put("apiUsesMultipartRelated", true);
|
||||
additionalProperties.put("apiUsesMultipart", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op1.formParams) {
|
||||
if (p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
op.vendorExtensions.put("x-consumes-media-index", collectMediaList(mediaList));
|
||||
}
|
||||
|
||||
if (op.summary != null) {
|
||||
op.summary = op.summary.trim();
|
||||
}
|
||||
if (op.notes != null) {
|
||||
op.notes = op.notes.trim();
|
||||
}
|
||||
op.vendorExtensions.put("x-has-notes", op.notes != null && op.notes.length() > 0);
|
||||
final String prefix = modelPackage() + ".Models";
|
||||
|
||||
// Set the file parameter type for both allParams and formParams.
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p.isFormParam && p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
// Convert optional parameters to use the Nullable_<T> type.
|
||||
if (!p.required && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
p.dataType = nullableTypeMapping.get(p.dataType);
|
||||
}
|
||||
|
||||
// Given the operation scopes and the auth methods, build a list of auth methods that only
|
||||
// describe the auth methods and scopes required by the operation.
|
||||
final Map<String, List<String>> scopes = (Map<String, List<String>>) op1.vendorExtensions.get("x-scopes");
|
||||
List<CodegenSecurity> opScopes = postProcessAuthMethod(op1.authMethods, scopes);
|
||||
if (opScopes != null) {
|
||||
op1.vendorExtensions.put("x-auth-scopes", opScopes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the path parameter to construct a x-path-index that tells the index of
|
||||
* the path parameter.
|
||||
*/
|
||||
for (CodegenParameter p : op1.pathParams) {
|
||||
String path = op1.path;
|
||||
int pos = 0;
|
||||
int index = 0;
|
||||
while (pos >= 0 && pos < path.length()) {
|
||||
int last;
|
||||
pos = path.indexOf('{', pos);
|
||||
if (pos < 0) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
last = path.indexOf('}', pos);
|
||||
index++;
|
||||
if (last < 0) {
|
||||
break;
|
||||
}
|
||||
if (path.substring(pos, last).equals(p.baseName)) {
|
||||
break;
|
||||
}
|
||||
pos = last + 1;
|
||||
String dataType;
|
||||
if (p.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
dataType = (String)p.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
} else {
|
||||
CodegenProperty schema = p.getSchema();
|
||||
if (schema != null) {
|
||||
dataType = (String) schema.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
} else {
|
||||
dataType = p.dataType;
|
||||
}
|
||||
p.vendorExtensions.put("x-path-index", index);
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
}
|
||||
String pkgName = useType(dataType);
|
||||
if (pkgName != null && !pkgName.startsWith(prefix)) {
|
||||
adaImportSet.add(pkgName);
|
||||
}
|
||||
p.vendorExtensions.put("x-is-imported-type", pkgName != null);
|
||||
p.vendorExtensions.put("x-is-model-type", isModelType(p));
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType(p));
|
||||
}
|
||||
for (CodegenParameter p : op.formParams) {
|
||||
if (p.isFile) {
|
||||
p.dataType = openApiPackageName + ".File_Part_Type";
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
|
||||
// Given the operation scopes and the auth methods, build a list of auth methods that only
|
||||
// describe the auth methods and scopes required by the operation.
|
||||
final Map<String, List<String>> scopes = (Map<String, List<String>>) op.vendorExtensions.get("x-scopes");
|
||||
List<CodegenSecurity> opScopes = postProcessAuthMethod(op.authMethods, scopes);
|
||||
if (opScopes != null) {
|
||||
op.vendorExtensions.put("x-auth-scopes", opScopes);
|
||||
}
|
||||
|
||||
CodegenProperty returnProperty = op.returnProperty;
|
||||
if (returnProperty != null) {
|
||||
CodegenProperty itemType = returnProperty.getItems();
|
||||
if (itemType != null) {
|
||||
String dataType;
|
||||
if (itemType.vendorExtensions.containsKey(X_ADA_VECTOR_TYPE_NAME)) {
|
||||
dataType = (String) itemType.vendorExtensions.get(X_ADA_VECTOR_TYPE_NAME);
|
||||
returnProperty.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
}
|
||||
returnProperty.vendorExtensions.put("x-is-model-type", isModelType(itemType));
|
||||
returnProperty.vendorExtensions.put("x-is-stream-type", isStreamType(itemType));
|
||||
} else {
|
||||
if (!returnProperty.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
returnProperty.vendorExtensions.put(X_ADA_TYPE_NAME, returnProperty.dataType);
|
||||
}
|
||||
returnProperty.vendorExtensions.put("x-is-model-type", isModelType(returnProperty));
|
||||
returnProperty.vendorExtensions.put("x-is-stream-type", isStreamType(returnProperty));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the path parameter to construct a x-path-index that tells the index of
|
||||
* the path parameter.
|
||||
*/
|
||||
for (CodegenParameter p : op.pathParams) {
|
||||
String path = op.path;
|
||||
int pos = 0;
|
||||
int index = 0;
|
||||
while (pos >= 0 && pos < path.length()) {
|
||||
int last;
|
||||
pos = path.indexOf('{', pos);
|
||||
if (pos < 0) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
last = path.indexOf('}', pos);
|
||||
index++;
|
||||
if (last < 0) {
|
||||
break;
|
||||
}
|
||||
if (path.substring(pos, last).equals(p.baseName)) {
|
||||
break;
|
||||
}
|
||||
pos = last + 1;
|
||||
}
|
||||
p.vendorExtensions.put("x-path-index", index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to sort the model according to their dependencies and names.
|
||||
*/
|
||||
static class ModelDepend implements Comparable<ModelDepend> {
|
||||
final List<String> depend;
|
||||
final ModelMap model;
|
||||
final String name;
|
||||
|
||||
ModelDepend(ModelMap model, List<String> depend, String name) {
|
||||
this.model = model;
|
||||
this.depend = depend;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int compareTo(ModelDepend second) {
|
||||
|
||||
if (depend != null && depend.contains(second.name)) {
|
||||
LOGGER.debug("Compare " + name + " with " + second.name + "=1");
|
||||
return 1;
|
||||
}
|
||||
if (second.depend != null && second.depend.contains(name)) {
|
||||
LOGGER.debug("Compare " + name + " with " + second.name + "=-1");
|
||||
return -1;
|
||||
}
|
||||
if ((depend == null ? 0 : depend.size()) != (second.depend == null ? 0 : second.depend.size())) {
|
||||
LOGGER.debug("Compare " + name + " with " + second.name + "=D"
|
||||
+ (depend.size() - second.depend.size()));
|
||||
return depend.size() - second.depend.size();
|
||||
}
|
||||
LOGGER.debug("Compare " + name + " with " + second.name + "=<name>");
|
||||
return name.compareTo(second.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
|
||||
// This is run first, before the operations.
|
||||
// remove model imports to avoid error
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
final String prefix = modelPackage() + ".Models";
|
||||
Iterator<Map<String, String>> iterator = imports.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String _import = iterator.next().get("import");
|
||||
if (_import.startsWith(prefix))
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
// Collect the model dependencies.
|
||||
for (ModelMap model : objs.getModels()) {
|
||||
CodegenModel m = model.getModel();
|
||||
@ -689,19 +852,56 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
for (CodegenProperty p : m.vars) {
|
||||
boolean isModel = false;
|
||||
CodegenProperty item = p;
|
||||
String dataType = null;
|
||||
String arrayDataType = null;
|
||||
if (p.vendorExtensions.containsKey(X_ADA_TYPE_NAME)) {
|
||||
dataType = (String)p.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
LOGGER.info("Data type {} mapped to {}", p.dataType, dataType);
|
||||
}
|
||||
arrayDataType = (String)p.vendorExtensions.get(X_ADA_VECTOR_TYPE_NAME);
|
||||
if (p.isContainer) {
|
||||
item = p.items;
|
||||
}
|
||||
if (item != null && !item.isString && !item.isPrimitiveType && !item.isContainer && !item.isInteger) {
|
||||
if (!d.contains(item.dataType)) {
|
||||
boolean isStreamType = isStreamType(p);
|
||||
if (!isStreamType && item != null && !item.isString && !item.isPrimitiveType && !item.isContainer && !item.isInteger) {
|
||||
if (dataType == null) {
|
||||
dataType = item.dataType;
|
||||
if (dataType.startsWith(modelPackage + ".Models.") || item.isFreeFormObject) {
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, dataType);
|
||||
} else {
|
||||
p.vendorExtensions.put(X_ADA_TYPE_NAME, modelPackage + ".Models." + dataType);
|
||||
}
|
||||
LOGGER.debug("Setting ada-type name {} for datatype {}", modelPackage + ".Models." + dataType,
|
||||
dataType);
|
||||
}
|
||||
if (!d.contains(dataType)) {
|
||||
// LOGGER.info("Model " + m.name + " uses " + p.datatype);
|
||||
d.add(item.dataType);
|
||||
d.add(dataType);
|
||||
}
|
||||
isModel = true;
|
||||
}
|
||||
Boolean noVector = Boolean.FALSE;
|
||||
if (p.vendorExtensions.get(X_ADA_NO_VECTOR) instanceof Boolean) {
|
||||
noVector = (Boolean) p.vendorExtensions.get(X_ADA_NO_VECTOR);
|
||||
}
|
||||
p.vendorExtensions.put(X_ADA_NO_VECTOR, noVector);
|
||||
p.vendorExtensions.put("x-is-model-type", isModel);
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType(p));
|
||||
p.vendorExtensions.put("x-is-stream-type", isStreamType);
|
||||
String pkgImport = useType(dataType);
|
||||
p.vendorExtensions.put("x-is-imported-type", pkgImport != null);
|
||||
if (pkgImport != null) {
|
||||
adaImportSet.add(pkgImport);
|
||||
}
|
||||
Boolean required = p.getRequired();
|
||||
if (!p.vendorExtensions.containsKey(X_ADA_SERIALIZE_OP)) {
|
||||
if (p.isLong && !required) {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
} else if (p.isLong && "int64".equals(p.dataFormat)) {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Long_Entity");
|
||||
} else {
|
||||
p.vendorExtensions.put(X_ADA_SERIALIZE_OP, "Write_Entity");
|
||||
}
|
||||
}
|
||||
|
||||
// Convert optional members to use the Nullable_<T> type.
|
||||
if (!Boolean.TRUE.equals(required) && nullableTypeMapping.containsKey(p.dataType)) {
|
||||
@ -710,53 +910,53 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
} else {
|
||||
p.vendorExtensions.put("x-is-required", true);
|
||||
}
|
||||
p.vendorExtensions.put("x-is-nullable", p.isNullable);
|
||||
}
|
||||
String name = (String) m.vendorExtensions.get(X_ADA_TYPE_NAME);
|
||||
if (name == null) {
|
||||
name = modelPackage + ".Models." + m.classname;
|
||||
m.vendorExtensions.put(X_ADA_TYPE_NAME, name);
|
||||
}
|
||||
String pkgName = useType(name);
|
||||
if (pkgName != null) {
|
||||
adaImportSet.add(pkgName);
|
||||
}
|
||||
m.vendorExtensions.put(X_ADA_TYPE_NAME, name);
|
||||
|
||||
m.vendorExtensions.put("x-is-imported-type", pkgName != null);
|
||||
// let us work with fully qualified names only
|
||||
modelDepends.put(modelPackage + ".Models." + m.classname, d);
|
||||
modelDepends.put(name, d);
|
||||
orderedModels.add(model);
|
||||
}
|
||||
|
||||
objs.setImports(imports);
|
||||
|
||||
// Sort models using dependencies:
|
||||
// List revisedOrderedModels <- ()
|
||||
// if you have N model, do N passes. In each pass look for an independent model
|
||||
// cycle over orderedModels
|
||||
// if I find a model that has no dependencies, or all of its dependencies are in revisedOrderedModels, consider it the independentModel
|
||||
// put the independentModel at the end of revisedOrderedModels, and remove it from orderedModels
|
||||
//
|
||||
List<ModelMap> revisedOrderedModels = new ArrayList<>();
|
||||
List<String> collectedModelNames = new ArrayList<>();
|
||||
int sizeOrderedModels = orderedModels.size();
|
||||
for (int i = 0; i < sizeOrderedModels; i++) {
|
||||
ModelMap independentModel = null;
|
||||
String independentModelName = null;
|
||||
for (ModelMap model : orderedModels) {
|
||||
// let us work with fully qualified names only
|
||||
String modelName = modelPackage + ".Models." + model.getModel().classname;
|
||||
boolean dependent = false;
|
||||
for (String dependency : modelDepends.get(modelName)) {
|
||||
if (!collectedModelNames.contains(dependency)) {
|
||||
dependent = true;
|
||||
}
|
||||
}
|
||||
if (!dependent) {
|
||||
// this model was independent
|
||||
independentModel = model;
|
||||
independentModelName = modelName;
|
||||
}
|
||||
}
|
||||
if (null != independentModel) {
|
||||
// I have find an independentModel. Add it to revisedOrderedModels, and remove from orderedModels
|
||||
revisedOrderedModels.add(independentModel);
|
||||
collectedModelNames.add(independentModelName);
|
||||
orderedModels.remove(independentModel);
|
||||
}
|
||||
TreeSet<ModelDepend> sorted = new TreeSet<>();
|
||||
for (ModelMap model : orderedModels) {
|
||||
String modelName = modelPackage + ".Models." + model.getModel().classname;
|
||||
sorted.add(new ModelDepend(model, modelDepends.get(modelName), modelName));
|
||||
}
|
||||
|
||||
// The comparison method in ModelDepend does not provide a total order
|
||||
// we have to adjust the sorted list to make sure the dependent models are
|
||||
// written last.
|
||||
ArrayList<ModelDepend> models = new ArrayList<>();
|
||||
for (ModelDepend item : sorted) {
|
||||
int pos = models.size();
|
||||
for (int i = 0; i < models.size(); i++) {
|
||||
ModelDepend second = models.get(i);
|
||||
if (second.depend != null && second.depend.contains(item.name)) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
models.add(pos, item);
|
||||
}
|
||||
List<ModelMap> revisedOrderedModels = new ArrayList<>();
|
||||
for (ModelDepend model : models) {
|
||||
revisedOrderedModels.add(model.model);
|
||||
}
|
||||
// bookkeeping:
|
||||
// if I still have elements in orderedModels:
|
||||
// if it's NOT last time I postProcessModels(), it means there are some dependencies that were not considered yet. That's not a problem
|
||||
// if it's last iteration, there are circular dependencies.
|
||||
// In any case, I add models still in orderedModels to revisedOrderedModels
|
||||
revisedOrderedModels.addAll(orderedModels);
|
||||
orderedModels = revisedOrderedModels;
|
||||
|
||||
return postProcessModelsEnum(objs);
|
||||
@ -766,18 +966,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
objs.put("orderedModels", orderedModels);
|
||||
generateJSONSpecFile(objs);
|
||||
/* TODO do we still need the SWAGGER_HOST logic below
|
||||
Swagger swagger = (Swagger) objs.get("swagger");
|
||||
if (swagger != null) {
|
||||
String host = swagger.getBasePath();
|
||||
try {
|
||||
swagger.setHost("SWAGGER_HOST");
|
||||
objs.put("swagger-json", Json.pretty().writeValueAsString(swagger).replace("\r\n", "\n"));
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
swagger.setHost(host);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Collect the scopes to generate unique identifiers for each of them.
|
||||
@ -788,6 +976,42 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
super.postProcessFile(file, fileType);
|
||||
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only process files with .ads or .adb extension
|
||||
String extension = FilenameUtils.getExtension(file.toString());
|
||||
if ("ads".equals(extension) || "adb".equals(extension)) {
|
||||
|
||||
String commandPrefix = System.getenv("ADA_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(commandPrefix)) {
|
||||
commandPrefix = "gnatpp";
|
||||
}
|
||||
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(new String[]{commandPrefix, "--no-compact", "--quiet", file.toString()});
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({} {}). Exit code: {}", commandPrefix, file, exitValue);
|
||||
} else {
|
||||
LOGGER.debug("Successfully executed: {} {}", commandPrefix, file);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
LOGGER.error("Error running the command ({} {}). Exception: {}", commandPrefix, file, e.getMessage());
|
||||
// Restore interrupted state
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.ADA; }
|
||||
|
||||
/**
|
||||
* Collect the scopes to generate a unique identifier for each of them.
|
||||
*
|
||||
@ -837,6 +1061,149 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.ADA; }
|
||||
private boolean isStreamType(CodegenProperty parameter) {
|
||||
return parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenProperty parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private boolean isStreamType(CodegenParameter parameter) {
|
||||
return parameter.isString || parameter.isBoolean || parameter.isDate
|
||||
|| parameter.isDateTime || parameter.isInteger || parameter.isLong
|
||||
|| (parameter.isFreeFormObject && !parameter.isMap);
|
||||
}
|
||||
|
||||
private boolean isModelType(CodegenParameter parameter) {
|
||||
boolean isModel = parameter.dataType.startsWith(modelPackage);
|
||||
if (!isModel && !parameter.isPrimitiveType && !parameter.isDate
|
||||
&& !parameter.isFreeFormObject
|
||||
&& !parameter.isString && !parameter.isContainer && !parameter.isFile
|
||||
&& !parameter.dataType.startsWith(openApiPackageName)) {
|
||||
isModel = true;
|
||||
}
|
||||
return isModel;
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getAuthScopes(List<SecurityRequirement> securities, Map<String, SecurityScheme> securitySchemes) {
|
||||
final Map<String, List<String>> scopes = new HashMap<>();
|
||||
Optional.ofNullable(securitySchemes).ifPresent(_securitySchemes -> {
|
||||
for (SecurityRequirement requirement : securities) {
|
||||
for (String key : requirement.keySet()) {
|
||||
Optional.ofNullable(securitySchemes.get(key))
|
||||
.ifPresent(securityScheme -> scopes.put(key, requirement.get(key)));
|
||||
}
|
||||
}
|
||||
});
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Ada type name is imported from another package.
|
||||
*
|
||||
* @param name the Ada full qualified type name.
|
||||
* @return true if this Ada type is imported.
|
||||
*/
|
||||
private String useType(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
int pos = name.lastIndexOf('.');
|
||||
if (pos <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String pkg = name.substring(0, pos);
|
||||
if (pkg.equals(modelPackage + ".Models")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return pkg;
|
||||
}
|
||||
|
||||
private boolean isMimetypeXml(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_XML) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_PROBLEM_XML) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(TEXT_XML);
|
||||
}
|
||||
|
||||
private boolean isMimetypeJson(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_JSON) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_MERGE_PATCH_JSON) ||
|
||||
mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_PROBLEM_JSON);
|
||||
}
|
||||
|
||||
private boolean isMimetypeWwwFormUrlEncoded(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_X_WWW_FORM_URLENCODED);
|
||||
}
|
||||
|
||||
private boolean isMimetypeMultipartFormData(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
|
||||
}
|
||||
|
||||
private boolean isMimetypeOctetStream(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
private boolean isMimetypeMultipartRelated(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/related");
|
||||
}
|
||||
|
||||
private boolean isMimetypeUnknown(String mimetype) {
|
||||
return "*/*".equals(mimetype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have any special handling for this mimetype?
|
||||
*/
|
||||
private boolean isMimetypePlain(String mimetype) {
|
||||
return !(isMimetypeUnknown(mimetype) ||
|
||||
isMimetypeXml(mimetype) ||
|
||||
isMimetypeJson(mimetype) ||
|
||||
isMimetypeWwwFormUrlEncoded(mimetype) ||
|
||||
isMimetypeMultipartFormData(mimetype) ||
|
||||
isMimetypeMultipartRelated(mimetype));
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect the list of media types to emit unique arrays of media types.
|
||||
* An array represents a list of media types and it can be referenced by several operations.
|
||||
* These arrays are emitted at the top of the client/server body packages.
|
||||
*
|
||||
* @param mediaList the list of media types.
|
||||
* @return the unique index assigned to that media list.
|
||||
*/
|
||||
private int collectMediaList(List<String> mediaList) {
|
||||
for (int i = 0; i < mediaGroups.size(); i++) {
|
||||
if (mediaList.equals(mediaGroups.get(i))) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
mediaGroups.add(mediaList);
|
||||
List<NameBinding> varList = new ArrayList<>();
|
||||
int pos = 0;
|
||||
for (String media : mediaList) {
|
||||
String varName = mediaToVariableName.get(media);
|
||||
if (varName == null) {
|
||||
varName = "Mime_" + (mediaVariables.size() + 1);
|
||||
mediaVariables.add(new NameBinding(mediaVariables.size() + 1, varName, media));
|
||||
varName = varName + "'Access";
|
||||
}
|
||||
pos++;
|
||||
varList.add(new NameBinding(pos, varName, media));
|
||||
}
|
||||
mediaLists.add(varList);
|
||||
return mediaGroups.size();
|
||||
}
|
||||
}
|
||||
|
@ -36,26 +36,6 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
|
||||
public AdaCodegen() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ada";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates an Ada client implementation (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.excludeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
@ -82,6 +62,26 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
)
|
||||
.includeClientModificationFeatures(ClientModificationFeature.BasePath)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ada";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates an Ada client implementation (beta).";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
|
||||
@ -120,6 +120,7 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
additionalProperties.put("isServer", false);
|
||||
additionalProperties.put("httpClientPackageName", httpClientPackageName);
|
||||
additionalProperties.put("openApiPackageName", openApiPackageName);
|
||||
additionalProperties.put("openApiGprName", openApiPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||
|
||||
String[] names = this.modelPackage.split("\\.");
|
||||
|
@ -123,6 +123,7 @@ public class AdaServerCodegen extends AbstractAdaCodegen implements CodegenConfi
|
||||
additionalProperties.put("isServer", "true");
|
||||
additionalProperties.put("httpClientPackageName", httpClientPackageName);
|
||||
additionalProperties.put("openApiPackageName", openApiPackageName);
|
||||
additionalProperties.put("openApiGprName", openApiPackageName.toLowerCase(Locale.ROOT));
|
||||
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
|
||||
|
||||
String names[] = this.modelPackage.split("\\.");
|
||||
|
@ -2,7 +2,18 @@
|
||||
pragma Warnings (Off, "*is not referenced");
|
||||
with {{openApiPackageName}}.Streams;
|
||||
package body {{package}}.Clients is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
{{#mediaVariables}}
|
||||
{{name}} : aliased constant String := "{{value}}";
|
||||
{{/mediaVariables}}
|
||||
{{#mediaLists}}
|
||||
Media_List_{{-index}} : constant {{openApiPackageName}}.Mime_List := ({{#this}}
|
||||
{{-index}} => {{name}}{{^-last}},
|
||||
{{/-last}}
|
||||
{{/this}});
|
||||
{{/mediaLists}}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
@ -12,8 +23,8 @@ package body {{package}}.Clients is
|
||||
-- {{#lambdaAdaComment}}{{unescapedNotes}}{{/lambdaAdaComment}}{{/vendorExtensions.x-has-notes}}
|
||||
procedure {{operationId}}
|
||||
(Client : in out Client_Type{{#hasParams}};{{/hasParams}}{{#allParams}}
|
||||
{{paramName}} : in {{^isFile}}{{^isString}}{{^isPrimitiveType}}{{^isContainer}}{{package}}.Models.{{/isContainer}}{{/isPrimitiveType}}{{/isString}}{{/isFile}}{{dataType}}{{^-last}};{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}}) is
|
||||
{{paramName}} : in {{^isFile}}{{^isString}}{{^isPrimitiveType}}{{^isContainer}}{{package}}.Models.{{/isContainer}}{{/isPrimitiveType}}{{/isString}}{{/isFile}}{{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{/returnProperty}}) is
|
||||
URI : {{openApiPackageName}}.Clients.URI_Type;{{#hasBodyParam}}
|
||||
Req : {{openApiPackageName}}.Clients.Request_Type;{{/hasBodyParam}}{{#hasFormParams}}
|
||||
Req : {{openApiPackageName}}.Clients.Request_Type;{{/hasFormParams}}
|
||||
@ -21,35 +32,36 @@ package body {{package}}.Clients is
|
||||
Reply : {{openApiPackageName}}.Value_Type;
|
||||
{{/returnType}}
|
||||
begin
|
||||
{{#hasProduces}}
|
||||
Client.Set_Accept (({{#produces}}{{#vendorExtensions.x-has-uniq-produces}}1 => {{/vendorExtensions.x-has-uniq-produces}}{{openApiPackageName}}.Clients.{{adaMediaType}}{{^-last}},
|
||||
{{/-last}}{{/produces}}));{{/hasProduces}}{{#hasBodyParam}}
|
||||
Client.Initialize (Req, ({{#hasConsumes}}{{#consumes}}{{#vendorExtensions.x-has-uniq-consumes}}1 => {{/vendorExtensions.x-has-uniq-consumes}}{{openApiPackageName}}.Clients.{{adaMediaType}}{{^-last}},
|
||||
{{/-last}}{{/consumes}}{{/hasConsumes}}{{^hasConsumes}}1 => {{openApiPackageName}}.Clients.APPLICATION_JSON{{/hasConsumes}}));{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{#vendorExtensions.x-produces-media-index}}
|
||||
Client.Set_Accept (Media_List_{{vendorExtensions.x-produces-media-index}});
|
||||
{{/vendorExtensions.x-produces-media-index}}
|
||||
{{#hasBodyParam}}
|
||||
Client.Initialize (Req{{#hasConsumes}}, Media_List_{{vendorExtensions.x-consumes-media-index}}{{/hasConsumes}});{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{package}}.Models.Serialize (Req.Stream, "", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{#isFile}}
|
||||
-- TODO: Serialize (Req.Stream, "{{basename}}", {{paramName}});{{/isFile}}{{^isFile}}{{^isLong}}
|
||||
Req.Stream.Write_Entity ("{{baseName}}", {{paramName}});{{/isLong}}{{#isLong}}
|
||||
Serialize (Req.Stream, "{{baseName}}", {{paramName}});{{/isLong}}{{/isFile}}{{/vendorExtensions.x-is-model-type}}{{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}
|
||||
Client.Initialize (Req, (1 => {{openApiPackageName}}.Clients.APPLICATION_FORM));{{#formParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
Client.Initialize (Req, Media_List_{{vendorExtensions.x-consumes-media-index}});{{#formParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{package}}.Models.Serialize (Req.Stream, "{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
Req.Stream.Write_Entity ("{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{/formParams}}{{/hasFormParams}}
|
||||
{{#queryParams}}{{#isQueryParam}}{{^isPrimitiveType}}{{^isString}}{{^isContainer}}{{^isDateTime}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/isDateTime}}{{/isContainer}}{{/isString}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{^isLong}}
|
||||
{{#queryParams}}{{#isQueryParam}}{{^isPrimitiveType}}{{^isString}}{{^isContainer}}{{^isDateTime}}{{#vendorExtensions.x-is-model-type}}
|
||||
URI.Add_Param ("{{baseName}}", {{package}}.Models.To_String ({{paramName}}));{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{/isDateTime}}{{/isContainer}}{{/isString}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{^isLong}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/isLong}}{{/isPrimitiveType}}{{#isLong}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/isLong}}{{#isContainer}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/isContainer}}{{#isDateTime}}
|
||||
URI.Add_Param ("{{baseName}}", {{paramName}});{{/isDateTime}}{{/isQueryParam}}{{/queryParams}}
|
||||
URI.Set_Path ("{{path}}");{{#pathParams}}
|
||||
URI.Set_Path_Param ("{{baseName}}", {{^isString}}{{openApiPackageName}}.To_String ({{/isString}}{{paramName}}{{^isString}}){{/isString}});{{/pathParams}}
|
||||
URI.Set_Path_Param ("{{baseName}}", {{^isString}}{{#vendorExtensions.x-is-model-type}}{{package}}.Models{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{openApiPackageName}}{{/vendorExtensions.x-is-model-type}}.To_String ({{/isString}}{{paramName}}{{^isString}}){{/isString}});{{/pathParams}}
|
||||
Client.Call ({{openApiPackageName}}.Clients.{{httpMethod}}, URI{{#hasBodyParam}}, Req{{/hasBodyParam}}{{#hasFormParams}}, Req{{/hasFormParams}}{{#returnType}}, Reply{{/returnType}});
|
||||
{{#returnType}}
|
||||
{{#returnProperty}}
|
||||
{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Streams.Deserialize (Reply, "", Result);
|
||||
{{/vendorExtensions.x-is-model-type}}
|
||||
{{#vendorExtensions.x-is-model-type}}
|
||||
{{package}}.Models.Deserialize (Reply, "", Result);
|
||||
{{/vendorExtensions.x-is-model-type}}
|
||||
{{/returnType}}
|
||||
{{/returnProperty}}
|
||||
end {{operationId}};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -3,8 +3,10 @@
|
||||
{{/imports}}
|
||||
with {{package}}.Models;
|
||||
with {{openApiPackageName}}.Clients;
|
||||
{{#adaImports}}with {{name}};
|
||||
{{/adaImports}}
|
||||
package {{package}}.Clients is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
type Client_Type is new {{openApiPackageName}}.Clients.Client_Type with null record;
|
||||
|
||||
@ -16,8 +18,8 @@ package {{package}}.Clients is
|
||||
-- {{#lambdaAdaComment}}{{unescapedNotes}}{{/lambdaAdaComment}}{{/vendorExtensions.x-has-notes}}
|
||||
procedure {{operationId}}
|
||||
(Client : in out Client_Type{{#hasParams}};{{/hasParams}}{{#allParams}}
|
||||
{{paramName}} : in {{^isFile}}{{^isString}}{{^isPrimitiveType}}{{^isContainer}}{{package}}.Models.{{/isContainer}}{{/isPrimitiveType}}{{/isString}}{{/isFile}}{{dataType}}{{^-last}};{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}});
|
||||
{{paramName}} : in {{^isFile}}{{^isString}}{{^isPrimitiveType}}{{^isContainer}}{{package}}.Models.{{/isContainer}}{{/isPrimitiveType}}{{/isString}}{{/isFile}}{{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{/returnProperty}});
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -1,6 +1,18 @@
|
||||
-- ------------ EDIT NOTE ------------
|
||||
-- {{{appName}}}
|
||||
-- {{{appDescription}}}
|
||||
-- This file was generated with openapi-generator. You can modify it to implement
|
||||
-- the client. After you modify this file, you should add the following line
|
||||
-- to the .openapi-generator-ignore file:
|
||||
--
|
||||
-- src/{{packageName}}.ads
|
||||
--
|
||||
-- Then, you can drop this edit note comment.
|
||||
-- ------------ EDIT NOTE ------------
|
||||
with {{package}}.Clients;
|
||||
with {{package}}.Models;
|
||||
with {{openApiPackageName}};
|
||||
with {{openApiPackageName}}.Credentials.OAuth;
|
||||
with Util.Http.Clients.{{httpClientPackageName}};
|
||||
with Ada.Text_IO;
|
||||
with Ada.Command_Line;
|
||||
@ -30,9 +42,11 @@ begin
|
||||
declare
|
||||
Command : constant String := Ada.Command_Line.Argument (Arg);
|
||||
Item : constant String := Ada.Command_Line.Argument (Arg + 1);
|
||||
Cred : aliased {{openApiPackageName}}.Credentials.OAuth.OAuth2_Credential_Type;
|
||||
C : {{package}}.Clients.Client_Type;
|
||||
begin
|
||||
C.Set_Server (Server);
|
||||
C.Set_Credentials (Cred'Unchecked_Access);
|
||||
Arg := Arg + 2;
|
||||
|
||||
exception
|
||||
|
@ -10,9 +10,9 @@ with "utilada_sys";
|
||||
with "utilada_xml";
|
||||
with "utilada_http";
|
||||
with "security";
|
||||
with "swagger";{{#isServer}}
|
||||
with "{{openApiGprName}}";{{#isServer}}
|
||||
with "servletada";
|
||||
with "swagger_server";{{/isServer}}
|
||||
with "{{openApiGprName}}_server";{{/isServer}}
|
||||
project {{{projectName}}} is
|
||||
|
||||
Mains := ("{{{packageName}}}-{{{mainName}}}.adb");
|
||||
|
@ -1,30 +1,54 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
package body {{package}}.Models is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
pragma Warnings (Off, "*use clause for package*");
|
||||
|
||||
use {{openApiPackageName}}.Streams;
|
||||
|
||||
{{#orderedModels}}
|
||||
{{#model}}{{^isArray}}
|
||||
{{#orderedModels}}{{#model}}{{^isArray}}{{#isEnum}}
|
||||
function To_{{classname}} (Value : in String) return {{vendorExtensions.x-ada-type-name}} is
|
||||
begin{{#allowableValues}}{{#enumVars}}
|
||||
if Value = {{value}} then
|
||||
return {{vendorExtensions.x-ada-prefix}}{{&name}};
|
||||
end if;{{/enumVars}}{{/allowableValues}}
|
||||
raise Constraint_Error;
|
||||
end To_{{classname}};
|
||||
|
||||
function To_String (Value : in {{vendorExtensions.x-ada-type-name}}) return String is
|
||||
begin
|
||||
case Value is{{#allowableValues}}{{#enumVars}}
|
||||
when {{vendorExtensions.x-ada-prefix}}{{&name}} =>
|
||||
return {{value}};
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
end case;
|
||||
end To_String;
|
||||
{{/isEnum}}
|
||||
procedure Serialize (Into : in out {{openApiPackageName}}.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in {{classname}}) is
|
||||
begin
|
||||
Into.Start_Entity (Name);{{#vars}}{{#vendorExtensions.x-is-stream-type}}{{^isLong}}
|
||||
Into.Write_Entity ("{{baseName}}", Value.{{name}});{{/isLong}}{{#isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Into.Write_Long_Entity ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}
|
||||
Into.Write_Entity ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-required}}{{/isLong}}{{/vendorExtensions.x-is-stream-type}}{{^vendorExtensions.x-is-stream-type}}
|
||||
Value : in {{vendorExtensions.x-ada-type-name}}) is
|
||||
begin{{#isEnum}}
|
||||
Into.Write_Entity (Name, To_String (Value));{{/isEnum}}{{^isEnum}}
|
||||
Into.Start_Entity (Name);{{#vars}}{{#vendorExtensions.x-is-stream-type}}{{^isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not {{#isFreeFormObject}}{{openApiPackageName}}.Is_Null (Value.{{name}}){{/isFreeFormObject}}{{^isFreeFormObject}}Value.{{name}}.Is_Null{{/isFreeFormObject}} then
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{#isLong}}{{#vendorExtensions.x-is-required}}
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-required}}{{^vendorExtensions.x-is-required}}{{#vendorExtensions.x-is-nullable}}
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-nullable}}{{^vendorExtensions.x-is-nullable}}
|
||||
if not Value.{{name}}.Is_Null then
|
||||
Into.{{vendorExtensions.x-ada-serialize-op}} ("{{baseName}}", Value.{{name}});
|
||||
end if;{{/vendorExtensions.x-is-nullable}}{{/vendorExtensions.x-is-required}}{{/isLong}}{{/vendorExtensions.x-is-stream-type}}{{^vendorExtensions.x-is-stream-type}}
|
||||
Serialize (Into, "{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-stream-type}}{{/vars}}
|
||||
Into.End_Entity (Name);
|
||||
{{/isEnum}}
|
||||
end Serialize;
|
||||
{{^vendorExtensions.x-ada-no-vector}}
|
||||
|
||||
procedure Serialize (Into : in out {{openApiPackageName}}.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in {{classname}}_Vectors.Vector) is
|
||||
Value : in {{#vendorExtensions.x-ada-vector-type-name}}{{.}}{{/vendorExtensions.x-ada-vector-type-name}}{{^vendorExtensions.x-ada-vector-type-name}}{{classname}}_Vectors.Vector{{/vendorExtensions.x-ada-vector-type-name}}) is
|
||||
begin
|
||||
Into.Start_Array (Name);
|
||||
for Item of Value loop
|
||||
@ -32,22 +56,25 @@ package body {{package}}.Models is
|
||||
end loop;
|
||||
Into.End_Array (Name);
|
||||
end Serialize;
|
||||
{{/vendorExtensions.x-ada-no-vector}}
|
||||
|
||||
procedure Deserialize (From : in {{openApiPackageName}}.Value_Type;
|
||||
Name : in String;
|
||||
Value : out {{classname}}) is
|
||||
Value : out {{vendorExtensions.x-ada-type-name}}) is
|
||||
Object : {{openApiPackageName}}.Value_Type;
|
||||
begin
|
||||
{{openApiPackageName}}.Streams.Deserialize (From, Name, Object);{{#vars}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Streams.Deserialize (From, Name, Object);{{#isEnum}}
|
||||
Value := To_{{classname}} ({{openApiPackageName}}.To_String (Object));{{/isEnum}}{{^isEnum}}{{#vars}}{{#vendorExtensions.x-is-model-type}}
|
||||
Deserialize (Object, "{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Streams.Deserialize (Object, "{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-model-type}}{{/vars}}
|
||||
{{openApiPackageName}}.Streams.Deserialize (Object, "{{baseName}}", Value.{{name}});{{/vendorExtensions.x-is-model-type}}{{/vars}}{{/isEnum}}
|
||||
end Deserialize;
|
||||
{{^vendorExtensions.x-ada-no-vector}}
|
||||
|
||||
procedure Deserialize (From : in {{openApiPackageName}}.Value_Type;
|
||||
Name : in String;
|
||||
Value : out {{classname}}_Vectors.Vector) is
|
||||
Value : in out {{#vendorExtensions.x-ada-vector-type-name}}{{.}}{{/vendorExtensions.x-ada-vector-type-name}}{{^vendorExtensions.x-ada-vector-type-name}}{{classname}}_Vectors.Vector{{/vendorExtensions.x-ada-vector-type-name}}) is
|
||||
List : {{openApiPackageName}}.Value_Array_Type;
|
||||
Item : {{classname}};
|
||||
Item : {{vendorExtensions.x-ada-type-name}};
|
||||
begin
|
||||
Value.Clear;
|
||||
{{openApiPackageName}}.Streams.Deserialize (From, Name, List);
|
||||
@ -56,7 +83,7 @@ package body {{package}}.Models is
|
||||
Value.Append (Item);
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
{{/vendorExtensions.x-ada-no-vector}}
|
||||
{{/isArray}}{{/model}}
|
||||
{{/orderedModels}}
|
||||
|
||||
|
@ -1,43 +1,52 @@
|
||||
{{>licenseInfo}}
|
||||
{{#imports}}with {{import}};
|
||||
{{/imports}}
|
||||
with {{openApiPackageName}}.Streams;
|
||||
with Ada.Containers.Vectors;
|
||||
{{#adaImports}}with {{name}};
|
||||
{{/adaImports}}
|
||||
package {{package}}.Models is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
{{#orderedModels}}{{#model}}{{^isArray}}
|
||||
{{#title}} -- ------------------------------
|
||||
-- {{title}}{{#description}}
|
||||
-- {{#lambdaAdaComment}}{{description}}{{/lambdaAdaComment}}{{/description}}
|
||||
-- ------------------------------{{/title}}
|
||||
-- ------------------------------{{/title}}{{#isEnum}}{{^vendorExtensions.x-is-imported-type}}
|
||||
type {{classname}} is ({{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}});
|
||||
{{/vendorExtensions.x-is-imported-type}}
|
||||
|
||||
function To_{{classname}} (Value : in String) return {{vendorExtensions.x-ada-type-name}};
|
||||
|
||||
function To_String (Value : in {{classname}}) return String;
|
||||
{{/isEnum}}{{^isEnum}}{{^vendorExtensions.x-is-imported-type}}{{#hasVars}}
|
||||
type {{classname}} is
|
||||
record
|
||||
{{#vars}}
|
||||
{{name}} : {{dataType}};
|
||||
{{name}} : {{#isArray}}{{#vendorExtensions.x-ada-vector-type-name}}{{.}}{{/vendorExtensions.x-ada-vector-type-name}}{{^vendorExtensions.x-ada-vector-type-name}}{{dataType}}{{/vendorExtensions.x-ada-vector-type-name}};{{/isArray}}{{^isArray}}{{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};{{/isArray}}
|
||||
{{/vars}}
|
||||
end record;
|
||||
|
||||
{{/hasVars}}{{^hasVars}}
|
||||
type {{classname}} is new {{dataType}};
|
||||
{{/hasVars}}{{/vendorExtensions.x-is-imported-type}}{{/isEnum}}
|
||||
{{^vendorExtensions.x-is-imported-type}}{{^vendorExtensions.x-ada-no-vector}}
|
||||
package {{classname}}_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => {{classname}});
|
||||
Element_Type => {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{classname}}{{/vendorExtensions.x-ada-type-name}});{{/vendorExtensions.x-ada-no-vector}}{{/vendorExtensions.x-is-imported-type}}
|
||||
|
||||
procedure Serialize (Into : in out {{openApiPackageName}}.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in {{classname}});
|
||||
|
||||
Value : in {{vendorExtensions.x-ada-type-name}});
|
||||
{{^vendorExtensions.x-ada-no-vector}}
|
||||
procedure Serialize (Into : in out {{openApiPackageName}}.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in {{classname}}_Vectors.Vector);
|
||||
|
||||
Value : in {{#vendorExtensions.x-ada-vector-type-name}}{{.}}{{/vendorExtensions.x-ada-vector-type-name}}{{^vendorExtensions.x-ada-vector-type-name}}{{classname}}_Vectors.Vector{{/vendorExtensions.x-ada-vector-type-name}});
|
||||
{{/vendorExtensions.x-ada-no-vector}}
|
||||
procedure Deserialize (From : in {{openApiPackageName}}.Value_Type;
|
||||
Name : in String;
|
||||
Value : out {{classname}});
|
||||
|
||||
Value : out {{vendorExtensions.x-ada-type-name}});
|
||||
{{^vendorExtensions.x-ada-no-vector}}
|
||||
procedure Deserialize (From : in {{openApiPackageName}}.Value_Type;
|
||||
Name : in String;
|
||||
Value : out {{classname}}_Vectors.Vector);
|
||||
|
||||
Value : in out {{#vendorExtensions.x-ada-vector-type-name}}{{.}}{{/vendorExtensions.x-ada-vector-type-name}}{{^vendorExtensions.x-ada-vector-type-name}}{{classname}}_Vectors.Vector{{/vendorExtensions.x-ada-vector-type-name}});{{/vendorExtensions.x-ada-no-vector}}
|
||||
{{/isArray}}{{#isArray}}
|
||||
subtype {{classname}} is {{arrayModelType}}_Type_Vectors.Vector;
|
||||
{{/isArray}}{{/model}}
|
||||
|
@ -21,10 +21,10 @@ package body {{package}}.Servers is
|
||||
overriding
|
||||
procedure {{operationId}}
|
||||
(Server : in out Server_Type{{#hasParams}};{{/hasParams}}
|
||||
{{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}};
|
||||
Context : in out {{openApiPackageName}.Servers.Context_Type) is
|
||||
{{#allParams}}{{paramName}} : in {{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{vendorExtensions.x-ada-type-name}}{{/returnProperty}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
|
||||
begin
|
||||
null;
|
||||
end {{operationId}};
|
||||
|
@ -3,11 +3,19 @@ pragma Warnings (Off, "*is not referenced");
|
||||
with {{openApiPackageName}}.Streams;
|
||||
with {{openApiPackageName}}.Servers.Operation;
|
||||
package body {{package}}.Skeletons is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
pragma Warnings (Off, "*use clause for package*");
|
||||
|
||||
use {{openApiPackageName}}.Streams;
|
||||
|
||||
{{#mediaVariables}}
|
||||
{{name}} : aliased constant String := "{{value}}";
|
||||
{{/mediaVariables}}
|
||||
{{#mediaLists}}
|
||||
Media_List_{{-index}} : aliased constant {{openApiPackageName}}.Mime_List := ({{#this}}
|
||||
{{-index}} => {{name}}{{^-last}},
|
||||
{{/-last}}{{/this}});{{/mediaLists}}
|
||||
|
||||
package body Skeleton is
|
||||
|
||||
{{#apiInfo}}
|
||||
@ -19,7 +27,13 @@ package body {{package}}.Skeletons is
|
||||
new {{openApiPackageName}}.Servers.Operation
|
||||
(Handler => {{operationId}},
|
||||
Method => {{openApiPackageName}}.Servers.{{httpMethod}},
|
||||
URI => URI_Prefix & "{{path}}");
|
||||
URI => URI_Prefix & "{{path}}",
|
||||
{{#vendorExtensions.x-produces-media-index}}
|
||||
Mimes => Media_List_{{vendorExtensions.x-produces-media-index}}'Access);
|
||||
{{/vendorExtensions.x-produces-media-index}}
|
||||
{{^vendorExtensions.x-produces-media-index}}
|
||||
Mimes => null);
|
||||
{{/vendorExtensions.x-produces-media-index}}
|
||||
|
||||
-- {{summary}}
|
||||
procedure {{operationId}}
|
||||
@ -32,11 +46,11 @@ package body {{package}}.Skeletons is
|
||||
{{/hasBodyParam}}
|
||||
Impl : Implementation_Type;
|
||||
{{#allParams}}
|
||||
{{paramName}} : {{dataType}};
|
||||
{{paramName}} : {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};
|
||||
{{/allParams}}
|
||||
{{#returnType}}
|
||||
Result : {{.}};
|
||||
{{/returnType}}
|
||||
{{#returnProperty}}
|
||||
Result : {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};
|
||||
{{/returnProperty}}
|
||||
begin
|
||||
{{#vendorExtensions.x-auth-scopes}}
|
||||
if not Context.Is_Authenticated then
|
||||
@ -50,12 +64,16 @@ package body {{package}}.Skeletons is
|
||||
end if;
|
||||
{{/scopes}}
|
||||
{{/vendorExtensions.x-auth-scopes}}
|
||||
{{#queryParams}}
|
||||
{{#queryParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{paramName}} := To_{{dataType}} ({{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}"));
|
||||
{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}", {{paramName}});
|
||||
{{/queryParams}}
|
||||
{{#pathParams}}
|
||||
{{/vendorExtensions.x-is-model-type}}{{/queryParams}}
|
||||
{{#pathParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{paramName}} := To_{{dataType}} ({{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}));
|
||||
{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}, {{paramName}});
|
||||
{{/pathParams}}
|
||||
{{/vendorExtensions.x-is-model-type}}{{/pathParams}}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{openApiPackageName}}.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}});
|
||||
@ -63,7 +81,11 @@ package body {{package}}.Skeletons is
|
||||
{{/hasFormParams}}
|
||||
{{#hasParams}}
|
||||
{{#hasBodyParam}}
|
||||
{{openApiPackageName}}.Servers.Read (Req, Input);
|
||||
{{openApiPackageName}}.Servers.Read (Req, Media_List_{{vendorExtensions.x-consumes-media-index}}, Input);
|
||||
if {{openApiPackageName}}.Is_Null (Input) then
|
||||
Context.Set_Error (415, "Invalid content");
|
||||
return;
|
||||
end if;
|
||||
{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{package}}.Models.Deserialize (Input, "{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{#isFile}}
|
||||
-- TODO: Serialize (Input.Stream, "{{basename}}", {{paramName}});{{/isFile}}{{^isFile}}{{^isLong}}
|
||||
@ -83,13 +105,29 @@ package body {{package}}.Skeletons is
|
||||
{{/returnType}}
|
||||
{{/hasParams}}
|
||||
{{#returnType}}
|
||||
if Context.Get_Status = 200 then
|
||||
{{#responses}}
|
||||
if Context.Get_Status = {{code}} then{{#message}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}
|
||||
{{#schema}}
|
||||
{{#vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Write ({{openApiPackageName}}.To_String (Result));
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{^vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
|
||||
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
|
||||
Stream.End_Document;
|
||||
end if;{{/returnType}}
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{/schema}}
|
||||
return;
|
||||
end if;{{/responses}}{{/returnType}}
|
||||
end {{operationId}};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@ -128,11 +166,11 @@ package body {{package}}.Skeletons is
|
||||
Input : {{openApiPackageName}}.Value_Type;
|
||||
{{/hasBodyParam}}
|
||||
{{#allParams}}
|
||||
{{paramName}} : {{dataType}};
|
||||
{{paramName}} : {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};
|
||||
{{/allParams}}
|
||||
{{#returnType}}
|
||||
Result : {{.}};
|
||||
{{/returnType}}
|
||||
{{#returnProperty}}
|
||||
Result : {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};
|
||||
{{/returnProperty}}
|
||||
begin
|
||||
{{#vendorExtensions.x-auth-scopes}}
|
||||
if not Context.Is_Authenticated then
|
||||
@ -147,11 +185,16 @@ package body {{package}}.Skeletons is
|
||||
{{/scopes}}
|
||||
{{/vendorExtensions.x-auth-scopes}}
|
||||
{{#queryParams}}
|
||||
{{#vendorExtensions.x-is-model-type}}
|
||||
{{paramName}} := To_{{dataType}} ({{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}"));
|
||||
{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Servers.Get_Query_Parameter (Req, "{{baseName}}", {{paramName}});
|
||||
{{/queryParams}}
|
||||
{{#pathParams}}
|
||||
{{/vendorExtensions.x-is-model-type}}{{/queryParams}}
|
||||
{{#pathParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{paramName}} := To_{{dataType}} ({{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}));
|
||||
{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}
|
||||
{{openApiPackageName}}.Servers.Get_Path_Parameter (Req, {{vendorExtensions.x-path-index}}, {{paramName}});
|
||||
{{/pathParams}}
|
||||
{{/vendorExtensions.x-is-model-type}}{{/pathParams}}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{openApiPackageName}}.Servers.Get_Parameter (Context, "{{baseName}}", {{paramName}});
|
||||
@ -159,7 +202,7 @@ package body {{package}}.Skeletons is
|
||||
{{/hasFormParams}}
|
||||
{{#hasParams}}
|
||||
{{#hasBodyParam}}
|
||||
{{openApiPackageName}}.Servers.Read (Req, Input);
|
||||
{{openApiPackageName}}.Servers.Read (Req, Media_List_{{vendorExtensions.x-consumes-media-index}}, Input);
|
||||
{{#bodyParams}}{{#vendorExtensions.x-is-model-type}}
|
||||
{{package}}.Models.Deserialize (Input, "{{baseName}}", {{paramName}});{{/vendorExtensions.x-is-model-type}}{{^vendorExtensions.x-is-model-type}}{{#isFile}}
|
||||
-- TODO: Serialize (Input.Stream, "{{basename}}", {{paramName}});{{/isFile}}{{^isFile}}{{^isLong}}
|
||||
@ -179,20 +222,43 @@ package body {{package}}.Skeletons is
|
||||
{{/returnType}}
|
||||
{{/hasParams}}
|
||||
{{#returnType}}
|
||||
if Context.Get_Status = 200 then
|
||||
{{#responses}}
|
||||
if Context.Get_Status = {{code}} then{{#message}}
|
||||
Context.Set_Description ("{{message}}");{{/message}}
|
||||
{{#schema}}
|
||||
{{#vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Write ({{openApiPackageName}}.To_String (Result));
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{^vendorExtensions.x-produces-plain-text}}
|
||||
{{#isFile}}
|
||||
{{openApiPackageName}}.Streams.Write (Stream, Result);
|
||||
{{/isFile}}{{^isFile}}
|
||||
Stream.Start_Document;{{#vendorExtensions.x-codegen-response.isString}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}{{#returnTypeIsPrimitive}}
|
||||
{{openApiPackageName}}.Streams.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}
|
||||
{{package}}.Models.Serialize (Stream, "", Result);{{/returnTypeIsPrimitive}}{{/vendorExtensions.x-codegen-response.isString}}
|
||||
Stream.End_Document;
|
||||
end if;{{/returnType}}
|
||||
{{/isFile}}{{/vendorExtensions.x-produces-plain-text}}
|
||||
{{/schema}}
|
||||
return;
|
||||
end if;{{/responses}}{{/returnType}}
|
||||
end {{operationId}};
|
||||
|
||||
package API_{{operationId}} is
|
||||
new {{openApiPackageName}}.Servers.Operation
|
||||
(Handler => {{operationId}},
|
||||
Method => {{openApiPackageName}}.Servers.{{httpMethod}},
|
||||
URI => URI_Prefix & "{{path}}");
|
||||
URI => URI_Prefix & "{{path}}",
|
||||
{{#vendorExtensions.x-produces-media-index}}
|
||||
Mimes => Media_List_{{vendorExtensions.x-produces-media-index}}'Access);
|
||||
{{/vendorExtensions.x-produces-media-index}}
|
||||
{{^vendorExtensions.x-produces-media-index}}
|
||||
Mimes => null);
|
||||
{{/vendorExtensions.x-produces-media-index}}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
@ -219,9 +285,9 @@ package body {{package}}.Skeletons is
|
||||
-- {{summary}}
|
||||
{{#hasParams}}
|
||||
procedure {{operationId}}
|
||||
({{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}};
|
||||
({{#allParams}}{{paramName}} : in {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{/returnProperty}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
|
||||
begin
|
||||
Impl.{{operationId}}
|
||||
@ -233,7 +299,7 @@ package body {{package}}.Skeletons is
|
||||
{{/hasParams}}
|
||||
{{^hasParams}}
|
||||
{{#returnType}}
|
||||
procedure {{operationId}} (Result : out {{returnType}};
|
||||
procedure {{operationId}} (Result : out {{returnProperty.vendorExtensions.x-ada-type-name}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type) is
|
||||
begin
|
||||
Impl.{{operationId}} (Result, Context);
|
||||
|
@ -1,13 +1,13 @@
|
||||
{{>licenseInfo}}
|
||||
{{#imports}}with {{import}};
|
||||
{{/imports}}
|
||||
pragma Warnings (Off, "*is not referenced");
|
||||
pragma Warnings (Off, "*no entities of*are referenced");
|
||||
with {{openApiPackageName}}.Servers;
|
||||
with {{package}}.Models;
|
||||
with Security.Permissions;
|
||||
{{#adaImports}}with {{name}};
|
||||
{{/adaImports}}
|
||||
package {{package}}.Skeletons is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
pragma Warnings (Off, "*use clause for package*");
|
||||
use {{package}}.Models;
|
||||
type Server_Type is limited interface;
|
||||
@ -25,9 +25,9 @@ package {{package}}.Skeletons is
|
||||
-- {{#lambdaAdaComment}}{{unescapedNotes}}{{/lambdaAdaComment}}{{/vendorExtensions.x-has-notes}}
|
||||
procedure {{operationId}}
|
||||
(Server : in out Server_Type{{#hasParams}};{{/hasParams}}
|
||||
{{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}};
|
||||
{{#allParams}}{{paramName}} : in {{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{/returnProperty}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type) is abstract;
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@ -93,20 +93,20 @@ package {{package}}.Skeletons is
|
||||
-- {{summary}}
|
||||
{{#hasParams}}
|
||||
procedure {{operationId}}
|
||||
({{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}};
|
||||
({{#allParams}}{{paramName}} : in {{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{/returnProperty}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type);
|
||||
{{/hasParams}}
|
||||
{{^hasParams}}
|
||||
{{#returnType}}
|
||||
{{#returnProperty}}
|
||||
procedure {{operationId}}
|
||||
(Result : out {{returnType}};
|
||||
(Result : out {{#vendorExtensions.x-ada-type-name}}{{.}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
{{/returnProperty}}
|
||||
{{^returnProperty}}
|
||||
procedure {{operationId}} (Context : in out {{openApiPackageName}}.Servers.Context_Type);
|
||||
{{/returnType}}
|
||||
{{/returnProperty}}
|
||||
{{/hasParams}}
|
||||
|
||||
{{/operation}}
|
||||
|
@ -9,11 +9,12 @@
|
||||
--
|
||||
-- Then, you can drop this edit note comment.
|
||||
-- ------------ EDIT NOTE ------------
|
||||
{{#imports}}with {{import}};
|
||||
{{/imports}}
|
||||
with {{openApiPackageName}.Servers;
|
||||
with {{openApiPackageName}}.Servers;
|
||||
with {{package}}.Models;
|
||||
with {{package}}.Skeletons;
|
||||
{{#adaImports}}with {{name}};
|
||||
{{/adaImports}}
|
||||
|
||||
package {{package}}.Servers is
|
||||
pragma Warnings (Off, "*use clause for package*");
|
||||
use {{package}}.Models;
|
||||
@ -29,10 +30,10 @@ package {{package}}.Servers is
|
||||
overriding
|
||||
procedure {{operationId}}
|
||||
(Server : in out Server_Type{{#hasParams}};{{/hasParams}}
|
||||
{{#allParams}}{{paramName}} : in {{dataType}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnType}};
|
||||
Result : out {{.}}{{/returnType}};
|
||||
Context : in out {{openApiPackageName}.Servers.Context_Type);
|
||||
{{#allParams}}{{paramName}} : in {{#vendorExtensions.x-ada-type-name}}{{vendorExtensions.x-ada-type-name}}{{/vendorExtensions.x-ada-type-name}}{{^vendorExtensions.x-ada-type-name}}{{dataType}}{{/vendorExtensions.x-ada-type-name}}{{^-last}};
|
||||
{{/-last}}{{/allParams}}{{#returnProperty}};
|
||||
Result : out {{vendorExtensions.x-ada-type-name}}{{/returnProperty}};
|
||||
Context : in out {{openApiPackageName}}.Servers.Context_Type);
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
@ -1 +1 @@
|
||||
6.0.0-SNAPSHOT
|
||||
7.0.0-SNAPSHOT
|
@ -4,14 +4,27 @@
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
--
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
-- https://openapi-generator.tech
|
||||
-- Do not edit the class manually.
|
||||
|
||||
pragma Warnings (Off, "*is not referenced");
|
||||
with Swagger.Streams;
|
||||
package body Samples.Petstore.Clients is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
Mime_1 : aliased constant String := "multipart/form-data";
|
||||
Media_List_1 : constant Swagger.Mime_List := (
|
||||
1 => Swagger.Mime_Json,
|
||||
|
||||
2 => Swagger.Mime_Xml );
|
||||
Media_List_2 : constant Swagger.Mime_List := (
|
||||
1 => Swagger.Mime_Json );
|
||||
Media_List_3 : constant Swagger.Mime_List := (
|
||||
1 => Swagger.Mime_Form );
|
||||
Media_List_4 : constant Swagger.Mime_List := (
|
||||
1 => Mime_1'Access );
|
||||
|
||||
|
||||
-- Add a new pet to the store
|
||||
procedure Add_Pet
|
||||
@ -20,9 +33,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (Swagger.Clients.APPLICATION_JSON,
|
||||
Swagger.Clients.APPLICATION_XML));
|
||||
Client.Initialize (Req, Media_List_1);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/pet");
|
||||
@ -52,8 +63,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Add_Param ("status", Status);
|
||||
URI.Set_Path ("/pet/findByStatus");
|
||||
@ -70,8 +81,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Add_Param ("tags", Tags);
|
||||
URI.Set_Path ("/pet/findByTags");
|
||||
@ -88,8 +99,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Set_Path ("/pet/{petId}");
|
||||
URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id));
|
||||
@ -104,9 +115,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (Swagger.Clients.APPLICATION_JSON,
|
||||
Swagger.Clients.APPLICATION_XML));
|
||||
Client.Initialize (Req, Media_List_1);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/pet");
|
||||
@ -123,7 +132,7 @@ package body Samples.Petstore.Clients is
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_FORM));
|
||||
Client.Initialize (Req, Media_List_3);
|
||||
Req.Stream.Write_Entity ("name", Name);
|
||||
Req.Stream.Write_Entity ("status", Status);
|
||||
|
||||
@ -143,10 +152,11 @@ package body Samples.Petstore.Clients is
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_FORM));
|
||||
Client.Set_Accept (Media_List_2);
|
||||
|
||||
Client.Initialize (Req, Media_List_4);
|
||||
Req.Stream.Write_Entity ("additionalMetadata", Additional_Metadata);
|
||||
Req.Stream.Write_Entity ("file", File);
|
||||
-- Req.Stream.Write_Entity ("file", File);
|
||||
|
||||
URI.Set_Path ("/pet/{petId}/uploadImage");
|
||||
URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id));
|
||||
@ -176,7 +186,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_2);
|
||||
|
||||
|
||||
URI.Set_Path ("/store/inventory");
|
||||
Client.Call (Swagger.Clients.GET, URI, Reply);
|
||||
@ -192,8 +203,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Set_Path ("/store/order/{orderId}");
|
||||
URI.Set_Path_Param ("orderId", Swagger.To_String (Order_Id));
|
||||
@ -210,9 +221,8 @@ package body Samples.Petstore.Clients is
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
Client.Initialize (Req);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/store/order");
|
||||
@ -228,8 +238,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/user");
|
||||
@ -243,8 +252,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/user/createWithArray");
|
||||
@ -258,8 +266,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/user/createWithList");
|
||||
@ -288,8 +295,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Set_Path ("/user/{username}");
|
||||
URI.Set_Path_Param ("username", Username);
|
||||
@ -306,8 +313,8 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Reply : Swagger.Value_Type;
|
||||
begin
|
||||
Client.Set_Accept ((Swagger.Clients.APPLICATION_XML,
|
||||
Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Set_Accept (Media_List_1);
|
||||
|
||||
|
||||
URI.Add_Param ("username", Username);
|
||||
URI.Add_Param ("password", Password);
|
||||
@ -336,8 +343,7 @@ package body Samples.Petstore.Clients is
|
||||
URI : Swagger.Clients.URI_Type;
|
||||
Req : Swagger.Clients.Request_Type;
|
||||
begin
|
||||
|
||||
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
|
||||
Client.Initialize (Req);
|
||||
Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body);
|
||||
|
||||
URI.Set_Path ("/user/{username}");
|
||||
|
@ -4,14 +4,14 @@
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
--
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
-- https://openapi-generator.tech
|
||||
-- Do not edit the class manually.
|
||||
|
||||
with Samples.Petstore.Models;
|
||||
with Swagger.Clients;
|
||||
package Samples.Petstore.Clients is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
type Client_Type is new Swagger.Clients.Client_Type with null record;
|
||||
|
||||
|
@ -4,28 +4,31 @@
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
--
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
-- https://openapi-generator.tech
|
||||
-- Do not edit the class manually.
|
||||
|
||||
|
||||
package body Samples.Petstore.Models is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
pragma Warnings (Off, "*use clause for package*");
|
||||
|
||||
use Swagger.Streams;
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in ApiResponse_Type) is
|
||||
Value : in Samples.Petstore.Models.ApiResponse_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("code", Value.Code);
|
||||
Into.Write_Entity ("type", Value.P_Type);
|
||||
Into.Write_Entity ("message", Value.Message);
|
||||
if not Value.Code.Is_Null then
|
||||
Into.Write_Entity ("code", Value.Code);
|
||||
end if;
|
||||
if not Value.P_Type.Is_Null then
|
||||
Into.Write_Entity ("type", Value.P_Type);
|
||||
end if;
|
||||
if not Value.Message.Is_Null then
|
||||
Into.Write_Entity ("message", Value.Message);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
@ -42,7 +45,7 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out ApiResponse_Type) is
|
||||
Value : out Samples.Petstore.Models.ApiResponse_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
@ -53,9 +56,9 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out ApiResponse_Type_Vectors.Vector) is
|
||||
Value : in out ApiResponse_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : ApiResponse_Type;
|
||||
Item : Samples.Petstore.Models.ApiResponse_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
@ -65,64 +68,17 @@ package body Samples.Petstore.Models is
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Tag_Type) is
|
||||
Value : in Samples.Petstore.Models.Category_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Tag_Type_Vectors.Vector) is
|
||||
begin
|
||||
Into.Start_Array (Name);
|
||||
for Item of Value loop
|
||||
Serialize (Into, "", Item);
|
||||
end loop;
|
||||
Into.End_Array (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Tag_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
Swagger.Streams.Deserialize (Object, "id", Value.Id);
|
||||
Swagger.Streams.Deserialize (Object, "name", Value.Name);
|
||||
end Deserialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Tag_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Tag_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
for Data of List loop
|
||||
Deserialize (Data, "", Item);
|
||||
Value.Append (Item);
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Category_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
if not Value.Id.Is_Null then
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
end if;
|
||||
if not Value.Name.Is_Null then
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
@ -139,7 +95,7 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Category_Type) is
|
||||
Value : out Samples.Petstore.Models.Category_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
@ -149,9 +105,9 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Category_Type_Vectors.Vector) is
|
||||
Value : in out Category_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Category_Type;
|
||||
Item : Samples.Petstore.Models.Category_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
@ -161,76 +117,29 @@ package body Samples.Petstore.Models is
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type) is
|
||||
Value : in Samples.Petstore.Models.Order_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
Serialize (Into, "category", Value.Category);
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
Serialize (Into, "photoUrls", Value.Photo_Urls);
|
||||
Serialize (Into, "tags", Value.Tags);
|
||||
Into.Write_Entity ("status", Value.Status);
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type_Vectors.Vector) is
|
||||
begin
|
||||
Into.Start_Array (Name);
|
||||
for Item of Value loop
|
||||
Serialize (Into, "", Item);
|
||||
end loop;
|
||||
Into.End_Array (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Pet_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
Swagger.Streams.Deserialize (Object, "id", Value.Id);
|
||||
Deserialize (Object, "category", Value.Category);
|
||||
Swagger.Streams.Deserialize (Object, "name", Value.Name);
|
||||
Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls);
|
||||
Deserialize (Object, "tags", Value.Tags);
|
||||
Swagger.Streams.Deserialize (Object, "status", Value.Status);
|
||||
end Deserialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Pet_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Pet_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
for Data of List loop
|
||||
Deserialize (Data, "", Item);
|
||||
Value.Append (Item);
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Order_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
Into.Write_Entity ("petId", Value.Pet_Id);
|
||||
Into.Write_Entity ("quantity", Value.Quantity);
|
||||
Into.Write_Entity ("shipDate", Value.Ship_Date);
|
||||
Into.Write_Entity ("status", Value.Status);
|
||||
Into.Write_Entity ("complete", Value.Complete);
|
||||
if not Value.Id.Is_Null then
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
end if;
|
||||
if not Value.Pet_Id.Is_Null then
|
||||
Into.Write_Entity ("petId", Value.Pet_Id);
|
||||
end if;
|
||||
if not Value.Quantity.Is_Null then
|
||||
Into.Write_Entity ("quantity", Value.Quantity);
|
||||
end if;
|
||||
if not Value.Ship_Date.Is_Null then
|
||||
Into.Write_Entity ("shipDate", Value.Ship_Date);
|
||||
end if;
|
||||
if not Value.Status.Is_Null then
|
||||
Into.Write_Entity ("status", Value.Status);
|
||||
end if;
|
||||
if not Value.Complete.Is_Null then
|
||||
Into.Write_Entity ("complete", Value.Complete);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
@ -247,7 +156,7 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Order_Type) is
|
||||
Value : out Samples.Petstore.Models.Order_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
@ -261,9 +170,9 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Order_Type_Vectors.Vector) is
|
||||
Value : in out Order_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Order_Type;
|
||||
Item : Samples.Petstore.Models.Order_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
@ -273,22 +182,84 @@ package body Samples.Petstore.Models is
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Samples.Petstore.Models.Tag_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
if not Value.Id.Is_Null then
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
end if;
|
||||
if not Value.Name.Is_Null then
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in User_Type) is
|
||||
Value : in Tag_Type_Vectors.Vector) is
|
||||
begin
|
||||
Into.Start_Array (Name);
|
||||
for Item of Value loop
|
||||
Serialize (Into, "", Item);
|
||||
end loop;
|
||||
Into.End_Array (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Samples.Petstore.Models.Tag_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
Swagger.Streams.Deserialize (Object, "id", Value.Id);
|
||||
Swagger.Streams.Deserialize (Object, "name", Value.Name);
|
||||
end Deserialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : in out Tag_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Samples.Petstore.Models.Tag_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
for Data of List loop
|
||||
Deserialize (Data, "", Item);
|
||||
Value.Append (Item);
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Samples.Petstore.Models.User_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
Into.Write_Entity ("username", Value.Username);
|
||||
Into.Write_Entity ("firstName", Value.First_Name);
|
||||
Into.Write_Entity ("lastName", Value.Last_Name);
|
||||
Into.Write_Entity ("email", Value.Email);
|
||||
Into.Write_Entity ("password", Value.Password);
|
||||
Into.Write_Entity ("phone", Value.Phone);
|
||||
Into.Write_Entity ("userStatus", Value.User_Status);
|
||||
if not Value.Id.Is_Null then
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
end if;
|
||||
if not Value.Username.Is_Null then
|
||||
Into.Write_Entity ("username", Value.Username);
|
||||
end if;
|
||||
if not Value.First_Name.Is_Null then
|
||||
Into.Write_Entity ("firstName", Value.First_Name);
|
||||
end if;
|
||||
if not Value.Last_Name.Is_Null then
|
||||
Into.Write_Entity ("lastName", Value.Last_Name);
|
||||
end if;
|
||||
if not Value.Email.Is_Null then
|
||||
Into.Write_Entity ("email", Value.Email);
|
||||
end if;
|
||||
if not Value.Password.Is_Null then
|
||||
Into.Write_Entity ("password", Value.Password);
|
||||
end if;
|
||||
if not Value.Phone.Is_Null then
|
||||
Into.Write_Entity ("phone", Value.Phone);
|
||||
end if;
|
||||
if not Value.User_Status.Is_Null then
|
||||
Into.Write_Entity ("userStatus", Value.User_Status);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
@ -305,7 +276,7 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out User_Type) is
|
||||
Value : out Samples.Petstore.Models.User_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
@ -321,9 +292,66 @@ package body Samples.Petstore.Models is
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out User_Type_Vectors.Vector) is
|
||||
Value : in out User_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : User_Type;
|
||||
Item : Samples.Petstore.Models.User_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
for Data of List loop
|
||||
Deserialize (Data, "", Item);
|
||||
Value.Append (Item);
|
||||
end loop;
|
||||
end Deserialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Samples.Petstore.Models.Pet_Type) is
|
||||
begin
|
||||
Into.Start_Entity (Name);
|
||||
if not Value.Id.Is_Null then
|
||||
Into.Write_Entity ("id", Value.Id);
|
||||
end if;
|
||||
Serialize (Into, "category", Value.Category);
|
||||
Into.Write_Entity ("name", Value.Name);
|
||||
Serialize (Into, "photoUrls", Value.Photo_Urls);
|
||||
Serialize (Into, "tags", Value.Tags);
|
||||
if not Value.Status.Is_Null then
|
||||
Into.Write_Entity ("status", Value.Status);
|
||||
end if;
|
||||
Into.End_Entity (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type_Vectors.Vector) is
|
||||
begin
|
||||
Into.Start_Array (Name);
|
||||
for Item of Value loop
|
||||
Serialize (Into, "", Item);
|
||||
end loop;
|
||||
Into.End_Array (Name);
|
||||
end Serialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Samples.Petstore.Models.Pet_Type) is
|
||||
Object : Swagger.Value_Type;
|
||||
begin
|
||||
Swagger.Streams.Deserialize (From, Name, Object);
|
||||
Swagger.Streams.Deserialize (Object, "id", Value.Id);
|
||||
Deserialize (Object, "category", Value.Category);
|
||||
Swagger.Streams.Deserialize (Object, "name", Value.Name);
|
||||
Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls);
|
||||
Deserialize (Object, "tags", Value.Tags);
|
||||
Swagger.Streams.Deserialize (Object, "status", Value.Status);
|
||||
end Deserialize;
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : in out Pet_Type_Vectors.Vector) is
|
||||
List : Swagger.Value_Array_Type;
|
||||
Item : Samples.Petstore.Models.Pet_Type;
|
||||
begin
|
||||
Value.Clear;
|
||||
Swagger.Streams.Deserialize (From, Name, List);
|
||||
@ -334,5 +362,4 @@ package body Samples.Petstore.Models is
|
||||
end Deserialize;
|
||||
|
||||
|
||||
|
||||
end Samples.Petstore.Models;
|
||||
|
@ -4,14 +4,14 @@
|
||||
-- The version of the OpenAPI document: 1.0.0
|
||||
--
|
||||
--
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT.
|
||||
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
-- https://openapi-generator.tech
|
||||
-- Do not edit the class manually.
|
||||
|
||||
with Swagger.Streams;
|
||||
with Ada.Containers.Vectors;
|
||||
package Samples.Petstore.Models is
|
||||
pragma Style_Checks ("-mr");
|
||||
pragma Style_Checks ("-bmrIu");
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
@ -25,58 +25,23 @@ package Samples.Petstore.Models is
|
||||
Message : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
|
||||
package ApiResponse_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => ApiResponse_Type);
|
||||
Element_Type => Samples.Petstore.Models.ApiResponse_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in ApiResponse_Type);
|
||||
|
||||
Value : in Samples.Petstore.Models.ApiResponse_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in ApiResponse_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out ApiResponse_Type);
|
||||
|
||||
Value : out Samples.Petstore.Models.ApiResponse_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out ApiResponse_Type_Vectors.Vector);
|
||||
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
-- Pet Tag
|
||||
-- A tag for a pet
|
||||
-- ------------------------------
|
||||
type Tag_Type is
|
||||
record
|
||||
Id : Swagger.Nullable_Long;
|
||||
Name : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
package Tag_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Tag_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Tag_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Tag_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Tag_Type);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Tag_Type_Vectors.Vector);
|
||||
|
||||
Value : in out ApiResponse_Type_Vectors.Vector);
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
@ -89,62 +54,23 @@ package Samples.Petstore.Models is
|
||||
Name : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
|
||||
package Category_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Category_Type);
|
||||
Element_Type => Samples.Petstore.Models.Category_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Category_Type);
|
||||
|
||||
Value : in Samples.Petstore.Models.Category_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Category_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Category_Type);
|
||||
|
||||
Value : out Samples.Petstore.Models.Category_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Category_Type_Vectors.Vector);
|
||||
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
-- a Pet
|
||||
-- A pet for sale in the pet store
|
||||
-- ------------------------------
|
||||
type Pet_Type is
|
||||
record
|
||||
Id : Swagger.Nullable_Long;
|
||||
Category : Samples.Petstore.Models.Category_Type;
|
||||
Name : Swagger.UString;
|
||||
Photo_Urls : Swagger.UString_Vectors.Vector;
|
||||
Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector;
|
||||
Status : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
package Pet_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Pet_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Pet_Type);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Pet_Type_Vectors.Vector);
|
||||
|
||||
Value : in out Category_Type_Vectors.Vector);
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
@ -161,27 +87,53 @@ package Samples.Petstore.Models is
|
||||
Complete : Swagger.Nullable_Boolean;
|
||||
end record;
|
||||
|
||||
|
||||
package Order_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Order_Type);
|
||||
Element_Type => Samples.Petstore.Models.Order_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Order_Type);
|
||||
|
||||
Value : in Samples.Petstore.Models.Order_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Order_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Order_Type);
|
||||
|
||||
Value : out Samples.Petstore.Models.Order_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Order_Type_Vectors.Vector);
|
||||
Value : in out Order_Type_Vectors.Vector);
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
-- Pet Tag
|
||||
-- A tag for a pet
|
||||
-- ------------------------------
|
||||
type Tag_Type is
|
||||
record
|
||||
Id : Swagger.Nullable_Long;
|
||||
Name : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
|
||||
package Tag_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Samples.Petstore.Models.Tag_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Samples.Petstore.Models.Tag_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Tag_Type_Vectors.Vector);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Samples.Petstore.Models.Tag_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : in out Tag_Type_Vectors.Vector);
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
-- a User
|
||||
@ -199,26 +151,56 @@ package Samples.Petstore.Models is
|
||||
User_Status : Swagger.Nullable_Integer;
|
||||
end record;
|
||||
|
||||
|
||||
package User_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => User_Type);
|
||||
Element_Type => Samples.Petstore.Models.User_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in User_Type);
|
||||
|
||||
Value : in Samples.Petstore.Models.User_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in User_Type_Vectors.Vector);
|
||||
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out User_Type);
|
||||
|
||||
Value : out Samples.Petstore.Models.User_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out User_Type_Vectors.Vector);
|
||||
Value : in out User_Type_Vectors.Vector);
|
||||
|
||||
|
||||
-- ------------------------------
|
||||
-- a Pet
|
||||
-- A pet for sale in the pet store
|
||||
-- ------------------------------
|
||||
type Pet_Type is
|
||||
record
|
||||
Id : Swagger.Nullable_Long;
|
||||
Category : Samples.Petstore.Models.Category_Type;
|
||||
Name : Swagger.UString;
|
||||
Photo_Urls : Swagger.UString_Vectors.Vector;
|
||||
Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector;
|
||||
Status : Swagger.Nullable_UString;
|
||||
end record;
|
||||
|
||||
|
||||
package Pet_Type_Vectors is
|
||||
new Ada.Containers.Vectors (Index_Type => Positive,
|
||||
Element_Type => Samples.Petstore.Models.Pet_Type);
|
||||
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Samples.Petstore.Models.Pet_Type);
|
||||
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
|
||||
Name : in String;
|
||||
Value : in Pet_Type_Vectors.Vector);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : out Samples.Petstore.Models.Pet_Type);
|
||||
procedure Deserialize (From : in Swagger.Value_Type;
|
||||
Name : in String;
|
||||
Value : in out Pet_Type_Vectors.Vector);
|
||||
|
||||
|
||||
end Samples.Petstore.Models;
|
||||
|
@ -63,7 +63,7 @@ procedure Petstore is
|
||||
Need_Indent := False;
|
||||
Put ("URLs : ");
|
||||
for Url of Pet.Photo_Urls loop
|
||||
Put_Line ((if Need_Indent then " " else "") & Url);
|
||||
Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Url));
|
||||
Need_Indent := True;
|
||||
end loop;
|
||||
end if;
|
||||
@ -131,7 +131,7 @@ procedure Petstore is
|
||||
Status : Swagger.UString_Vectors.Vector;
|
||||
P : constant String := Ada.Command_Line.Argument (I);
|
||||
begin
|
||||
Status.Append (New_Item => P);
|
||||
Status.Append (New_Item => Swagger.To_UString (P));
|
||||
C.Find_Pets_By_Status (Status, Pets);
|
||||
for Pet of Pets loop
|
||||
Print_Pet (Pet);
|
||||
|
@ -1,6 +1,18 @@
|
||||
-- ------------ EDIT NOTE ------------
|
||||
-- OpenAPI Petstore
|
||||
-- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters.
|
||||
-- This file was generated with openapi-generator. You can modify it to implement
|
||||
-- the client. After you modify this file, you should add the following line
|
||||
-- to the .openapi-generator-ignore file:
|
||||
--
|
||||
-- src/samples-petstore.ads
|
||||
--
|
||||
-- Then, you can drop this edit note comment.
|
||||
-- ------------ EDIT NOTE ------------
|
||||
with Samples.Petstore.Clients;
|
||||
with Samples.Petstore.Models;
|
||||
with Swagger;
|
||||
with Swagger.Credentials.OAuth;
|
||||
with Util.Http.Clients.Curl;
|
||||
with Ada.Text_IO;
|
||||
with Ada.Command_Line;
|
||||
@ -30,9 +42,11 @@ begin
|
||||
declare
|
||||
Command : constant String := Ada.Command_Line.Argument (Arg);
|
||||
Item : constant String := Ada.Command_Line.Argument (Arg + 1);
|
||||
Cred : aliased Swagger.Credentials.OAuth.OAuth2_Credential_Type;
|
||||
C : Samples.Petstore.Clients.Client_Type;
|
||||
begin
|
||||
C.Set_Server (Server);
|
||||
C.Set_Credentials (Cred'Unchecked_Access);
|
||||
Arg := Arg + 2;
|
||||
|
||||
exception
|
||||
|
Loading…
x
Reference in New Issue
Block a user