diff --git a/src/gen/java/org/computate/vertx/writer/ApiWriterGen.java b/src/gen/java/org/computate/vertx/writer/ApiWriterGen.java index a7149ef..13b9201 100644 --- a/src/gen/java/org/computate/vertx/writer/ApiWriterGen.java +++ b/src/gen/java/org/computate/vertx/writer/ApiWriterGen.java @@ -1418,6 +1418,63 @@ public static String staticSearchFqClassIsBase(ComputateSiteRequest siteRequest_ return ApiWriter.staticSearchStrClassIsBase(siteRequest_, ApiWriter.staticSearchClassIsBase(siteRequest_, ApiWriter.staticSetClassIsBase(siteRequest_, o))); } + ///////////////// + // classFiware // + ///////////////// + + + /** The entity classFiware + * is defined as null before being initialized. + */ + @JsonProperty + @JsonInclude(Include.NON_NULL) + protected Boolean classFiware; + + /**
The entity classFiware + * is defined as null before being initialized. + *
Find the entity classFiware in Solr + *
+ * @param c is for wrapping a value to assign to this entity during initialization. + **/ + protected abstract void _classFiware(Wrap c); + + public Boolean getClassFiware() { + return classFiware; + } + + public void setClassFiware(Boolean classFiware) { + this.classFiware = classFiware; + } + @JsonIgnore + public void setClassFiware(String o) { + this.classFiware = ApiWriter.staticSetClassFiware(siteRequest_, o); + } + public static Boolean staticSetClassFiware(ComputateSiteRequest siteRequest_, String o) { + return Boolean.parseBoolean(o); + } + protected ApiWriter classFiwareInit() { + Wrap classFiwareWrap = new Wrap().var("classFiware"); + if(classFiware == null) { + _classFiware(classFiwareWrap); + Optional.ofNullable(classFiwareWrap.getO()).ifPresent(o -> { + setClassFiware(o); + }); + } + return (ApiWriter)this; + } + + public static Boolean staticSearchClassFiware(ComputateSiteRequest siteRequest_, Boolean o) { + return o; + } + + public static String staticSearchStrClassFiware(ComputateSiteRequest siteRequest_, Boolean o) { + return o == null ? null : o.toString(); + } + + public static String staticSearchFqClassFiware(ComputateSiteRequest siteRequest_, String o) { + return ApiWriter.staticSearchStrClassFiware(siteRequest_, ApiWriter.staticSearchClassFiware(siteRequest_, ApiWriter.staticSetClassFiware(siteRequest_, o))); + } + ///////////////////// // classSimpleName // ///////////////////// @@ -2867,6 +2924,7 @@ public void initApiWriter() { classApiTagInit(); classExtendsBaseInit(); classIsBaseInit(); + classFiwareInit(); classSimpleNameInit(); appNameInit(); classAbsolutePathInit(); @@ -3003,6 +3061,8 @@ public Object obtainApiWriter(String var) { return oApiWriter.classExtendsBase; case "classIsBase": return oApiWriter.classIsBase; + case "classFiware": + return oApiWriter.classFiware; case "classSimpleName": return oApiWriter.classSimpleName; case "appName": @@ -3112,6 +3172,8 @@ public static Object staticSetApiWriter(String entityVar, ComputateSiteRequest s return ApiWriter.staticSetClassExtendsBase(siteRequest_, o); case "classIsBase": return ApiWriter.staticSetClassIsBase(siteRequest_, o); + case "classFiware": + return ApiWriter.staticSetClassFiware(siteRequest_, o); case "classSimpleName": return ApiWriter.staticSetClassSimpleName(siteRequest_, o); case "appName": @@ -3198,6 +3260,8 @@ public static Object staticSearchApiWriter(String entityVar, ComputateSiteReques return ApiWriter.staticSearchClassExtendsBase(siteRequest_, (Boolean)o); case "classIsBase": return ApiWriter.staticSearchClassIsBase(siteRequest_, (Boolean)o); + case "classFiware": + return ApiWriter.staticSearchClassFiware(siteRequest_, (Boolean)o); case "classSimpleName": return ApiWriter.staticSearchClassSimpleName(siteRequest_, (String)o); case "appName": @@ -3284,6 +3348,8 @@ public static String staticSearchStrApiWriter(String entityVar, ComputateSiteReq return ApiWriter.staticSearchStrClassExtendsBase(siteRequest_, (Boolean)o); case "classIsBase": return ApiWriter.staticSearchStrClassIsBase(siteRequest_, (Boolean)o); + case "classFiware": + return ApiWriter.staticSearchStrClassFiware(siteRequest_, (Boolean)o); case "classSimpleName": return ApiWriter.staticSearchStrClassSimpleName(siteRequest_, (String)o); case "appName": @@ -3370,6 +3436,8 @@ public static String staticSearchFqApiWriter(String entityVar, ComputateSiteRequ return ApiWriter.staticSearchFqClassExtendsBase(siteRequest_, o); case "classIsBase": return ApiWriter.staticSearchFqClassIsBase(siteRequest_, o); + case "classFiware": + return ApiWriter.staticSearchFqClassFiware(siteRequest_, o); case "classSimpleName": return ApiWriter.staticSearchFqClassSimpleName(siteRequest_, o); case "appName": @@ -3460,6 +3528,7 @@ public static String staticSearchFqApiWriter(String entityVar, ComputateSiteRequ public static final String VAR_classApiTag = "classApiTag"; public static final String VAR_classExtendsBase = "classExtendsBase"; public static final String VAR_classIsBase = "classIsBase"; + public static final String VAR_classFiware = "classFiware"; public static final String VAR_classSimpleName = "classSimpleName"; public static final String VAR_appName = "appName"; public static final String VAR_classAbsolutePath = "classAbsolutePath"; @@ -3512,6 +3581,7 @@ public static String staticSearchFqApiWriter(String entityVar, ComputateSiteRequ public static final String DISPLAY_NAME_classApiTag = ""; public static final String DISPLAY_NAME_classExtendsBase = ""; public static final String DISPLAY_NAME_classIsBase = ""; + public static final String DISPLAY_NAME_classFiware = ""; public static final String DISPLAY_NAME_classSimpleName = ""; public static final String DISPLAY_NAME_appName = ""; public static final String DISPLAY_NAME_classAbsolutePath = ""; @@ -3595,6 +3665,8 @@ public static String displayNameApiWriter(String var) { return DISPLAY_NAME_classExtendsBase; case VAR_classIsBase: return DISPLAY_NAME_classIsBase; + case VAR_classFiware: + return DISPLAY_NAME_classFiware; case VAR_classSimpleName: return DISPLAY_NAME_classSimpleName; case VAR_appName: diff --git a/src/main/java/org/computate/vertx/openapi/Swagger2Generator.java b/src/main/java/org/computate/vertx/openapi/Swagger2Generator.java index 7baffbe..1ffffde 100644 --- a/src/main/java/org/computate/vertx/openapi/Swagger2Generator.java +++ b/src/main/java/org/computate/vertx/openapi/Swagger2Generator.java @@ -75,39 +75,6 @@ public Future writeApi() { JsonObject authClients = Optional.ofNullable(config.getValue(ComputateConfigKeys.AUTH_CLIENTS)).map(v -> v instanceof JsonObject ? (JsonObject)v : new JsonObject(v.toString())).orElse(new JsonObject()); wPaths.tl(0, "paths:"); - authClients.fieldNames().forEach(authClientOpenApiId -> { - JsonObject authClient = authClients.getJsonObject(authClientOpenApiId); - String authCallbackUri = authClient.getString(ComputateConfigKeys.AUTH_CALLBACK_URI); - String authLogoutUri = authClient.getString(ComputateConfigKeys.AUTH_LOGOUT_URI); - - wPaths.l(); - wPaths.tl(1, authCallbackUri, ":"); - wPaths.tl(2, "get:"); - wPaths.tl(3, "operationId: callback"); - wPaths.tl(3, "x-vertx-event-bus: ", appName, "-", languageName, "-", authClientOpenApiId, "-callback"); - wPaths.tl(3, "description: >+"); - wPaths.tl(3, "responses:"); - wPaths.tl(4, "'200':"); - wPaths.tl(5, "description: >+"); - wPaths.tl(5, "content:"); - wPaths.tl(6, "application/json; charset=utf-8:"); - wPaths.tl(7, "schema:"); - wPaths.tl(8, "type: string"); - wPaths.l(); - wPaths.tl(1, authLogoutUri, ":"); - wPaths.tl(2, "get:"); - wPaths.tl(3, "operationId: logout"); - wPaths.tl(3, "x-vertx-event-bus: ", appName, "-", languageName, "-", authClientOpenApiId, "-logout"); - wPaths.tl(3, "description: >+"); - wPaths.tl(3, "responses:"); - wPaths.tl(4, "'200':"); - wPaths.tl(5, "description: >+"); - wPaths.tl(5, "content:"); - wPaths.tl(6, "application/json; charset=utf-8:"); - wPaths.tl(7, "schema:"); - wPaths.tl(8, "type: string"); - wPaths.l(); - }); if(openApiVersionNumber == 2) { wSchemas.tl(0, "definitions:"); @@ -129,6 +96,45 @@ public Future writeApi() { } loadClasses().onSuccess(classDoc -> { + authClients.fieldNames().forEach(authClientOpenApiId -> { + JsonObject authClient = authClients.getJsonObject(authClientOpenApiId); + String authCallbackUri = authClient.getString(ComputateConfigKeys.AUTH_CALLBACK_URI); + String authLogoutUri = authClient.getString(ComputateConfigKeys.AUTH_LOGOUT_URI); + + wPaths.l(); + wPaths.tl(1, authLogoutUri, ":"); + wPaths.tl(2, "get:"); + wPaths.tl(3, "operationId: logout"); + wPaths.tl(3, "x-vertx-event-bus: ", appName, "-", languageName, "-", authClientOpenApiId, "-logout"); + wPaths.tl(3, "description: >+"); + wPaths.tl(3, "responses:"); + wPaths.tl(4, "'200':"); + wPaths.tl(5, "description: >+"); + wPaths.tl(5, "content:"); + wPaths.tl(6, "application/json; charset=utf-8:"); + wPaths.tl(7, "schema:"); + wPaths.tl(8, "type: string"); + }); + authClients.fieldNames().forEach(authClientOpenApiId -> { + JsonObject authClient = authClients.getJsonObject(authClientOpenApiId); + String authCallbackUri = authClient.getString(ComputateConfigKeys.AUTH_CALLBACK_URI); + String authLogoutUri = authClient.getString(ComputateConfigKeys.AUTH_LOGOUT_URI); + + wPaths.l(); + wPaths.tl(1, authCallbackUri, ":"); + wPaths.tl(2, "get:"); + wPaths.tl(3, "operationId: callback"); + wPaths.tl(3, "x-vertx-event-bus: ", appName, "-", languageName, "-", authClientOpenApiId, "-callback"); + wPaths.tl(3, "description: >+"); + wPaths.tl(3, "responses:"); + wPaths.tl(4, "'200':"); + wPaths.tl(5, "description: >+"); + wPaths.tl(5, "content:"); + wPaths.tl(6, "application/json; charset=utf-8:"); + wPaths.tl(7, "schema:"); + wPaths.tl(8, "type: string"); + }); + LOG.info("Write OpenAPI completed. "); promise.complete(); }).onFailure(ex -> { diff --git a/src/main/java/org/computate/vertx/writer/ApiWriter.java b/src/main/java/org/computate/vertx/writer/ApiWriter.java index 2a72cd7..ed17d63 100644 --- a/src/main/java/org/computate/vertx/writer/ApiWriter.java +++ b/src/main/java/org/computate/vertx/writer/ApiWriter.java @@ -126,6 +126,10 @@ protected void _classIsBase(Wrap c) { c.o((Boolean)classSolrDocument.get("classeEstBase_stored_boolean")); } + protected void _classFiware(Wrap c) { + c.o((Boolean)classSolrDocument.get("classeFiware_stored_boolean")); + } + protected void _classSimpleName(Wrap c) { c.o((String)classSolrDocument.get("classeNomSimple_enUS_stored_string")); } @@ -509,6 +513,24 @@ public void writeApi(Boolean id) throws Exception, Exception { wPaths.tl(3, "produces:"); wPaths.tl(4, "- ", classApiMediaType200Method); } + if(!id && classFiware) { + wRequestHeaders.tl(4, "- name: Fiware-Service"); + wRequestHeaders.tl(5, "in: header"); + wRequestHeaders.tl(5, "schema:"); + wRequestHeaders.tl(6, "type: string"); + wRequestHeaders.tl(4, "- name: Fiware-ServicePath"); + wRequestHeaders.tl(5, "in: header"); + wRequestHeaders.tl(5, "schema:"); + wRequestHeaders.tl(6, "type: string"); + wRequestHeaders.tl(4, "- name: NGSILD-Tenant"); + wRequestHeaders.tl(5, "in: header"); + wRequestHeaders.tl(5, "schema:"); + wRequestHeaders.tl(6, "type: string"); + wRequestHeaders.tl(4, "- name: NGSILD-Path"); + wRequestHeaders.tl(5, "in: header"); + wRequestHeaders.tl(5, "schema:"); + wRequestHeaders.tl(6, "type: string"); + } if(!wRequestHeaders.getEmpty() || "GET".equals(classApiMethodMethod) || "DELETE".equals(classApiMethodMethod) || "PUT".equals(classApiMethodMethod) || "PATCH".equals(classApiMethodMethod)) { wPaths.tl(3, "parameters:");