You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/12/11 15:35:59 UTC

[isis] branch master updated: ISIS-2158: swagger-ui: produces v1 profile only on 'objects'

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b82644  ISIS-2158: swagger-ui: produces v1 profile only on 'objects'
0b82644 is described below

commit 0b82644857da094a482adcdb88ae36c091137033
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Dec 11 16:35:51 2019 +0100

    ISIS-2158: swagger-ui: produces v1 profile only on 'objects'
    
    this restores behavior from earlier this day
---
 .../services/swagger/internal/Generation.java      | 36 +++++++++++++++-------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/swagger/internal/Generation.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/swagger/internal/Generation.java
index 0eeb589..626ae7c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/swagger/internal/Generation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/swagger/internal/Generation.java
@@ -18,7 +18,15 @@
  */
 package org.apache.isis.metamodel.services.swagger.internal;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.apache.isis.applib.annotation.SemanticsOf;
@@ -363,7 +371,7 @@ class Generation {
         swagger.path(String.format("/objects/%s/{objectId}", objectType), path);
 
         final String tag = tagForObjectType(objectType, null);
-        final Operation operation = new Operation();
+        final Operation operation = newOperation("object");
         path.get(operation);
         operation
         .tag(tag)
@@ -371,12 +379,7 @@ class Generation {
         .parameter(
                 new PathParameter()
                 .name("objectId")
-                .type("string"))
-        .produces("application/json;profile=urn:org.apache.isis/v1")
-        .produces("application/json;profile=urn:org.apache.isis/v1;suppress=true")
-        .produces("application/json;profile=urn:org.apache.isis/v1;suppress=all")
-        .produces("application/json;profile=urn:org.restfulobjects:repr-types/object");
-
+                .type("string"));
 
         // per https://github.com/swagger-api/swagger-spec/issues/146, swagger 2.0 doesn't support multiple
         // modelled representations per path and response code;
@@ -831,16 +834,27 @@ class Generation {
 
     private static Operation newOperation(String ... reprTypes) {
         Operation operation = new Operation()
-                .produces("application/json")
-                .produces("application/json;profile=urn:org.apache.isis/v1")
-                .produces("application/json;profile=urn:org.apache.isis/v1;suppress=all");
+                .produces("application/json");
+        
+        boolean supportsV1 = false;
                 
         if(reprTypes!=null) {
             for(String reprType: reprTypes) {
+                
+                if(reprType.equals("object") || reprType.equals("action-result")) {
+                    supportsV1 = true;
+                }
+                
                 operation = operation
                         .produces("application/json;profile=urn:org.restfulobjects:repr-types/" + reprType);
             }
         }
+        
+        if(supportsV1) {
+            operation = operation
+                .produces("application/json;profile=urn:org.apache.isis/v1")
+                .produces("application/json;profile=urn:org.apache.isis/v1;suppress=all");
+        }
                 
         return operation;
     }