18
18
import org .eclipse .microprofile .openapi .models .PathItem ;
19
19
import org .eclipse .microprofile .openapi .models .media .Schema ;
20
20
import org .junit .jupiter .api .BeforeAll ;
21
- import org .junit .jupiter .api .Test ;
22
21
import org .junit .jupiter .params .ParameterizedTest ;
23
22
import org .junit .jupiter .params .provider .MethodSource ;
24
23
25
- import com .fasterxml .jackson .databind .JsonNode ;
26
- import com .fasterxml .jackson .databind .ObjectMapper ;
27
- import com .fasterxml .jackson .dataformat .yaml .YAMLMapper ;
28
-
29
- import io .fabric8 .kubernetes .api .model .apiextensions .v1 .CustomResourceDefinition ;
30
- import io .fabric8 .kubernetes .api .model .apiextensions .v1 .CustomResourceDefinitionBuilder ;
31
- import io .fabric8 .kubernetes .api .model .apiextensions .v1 .CustomResourceDefinitionVersionBuilder ;
32
- import io .fabric8 .kubernetes .api .model .apiextensions .v1 .JSONSchemaPropsBuilder ;
33
- import io .fabric8 .kubernetes .client .utils .Serialization ;
34
24
import io .quarkus .smallrye .openapi .runtime .OpenApiConstants ;
35
25
import io .smallrye .openapi .api .OpenApiConfig ;
36
26
import io .smallrye .openapi .api .OpenApiConfigImpl ;
@@ -64,55 +54,6 @@ public static void setUp() {
64
54
throw new RuntimeException ("Could not find [" + OpenApiConstants .BASE_NAME + Format .JSON + "]" );
65
55
}
66
56
}
67
-
68
- @ Test
69
- public void test () {
70
- System .out .println (model .getComponents ().getResponses ().get ("Organization" ));
71
- ObjectMapper objectMapper = new ObjectMapper ();
72
- JsonNode jsonNodeTree ;
73
- try {
74
- jsonNodeTree = objectMapper .readTree (ResponseTypeMapperTest .class .getClassLoader ().getResourceAsStream ("gitea.json" ));
75
- String jsonAsYaml = new YAMLMapper ().writeValueAsString (jsonNodeTree .get ("components" ).get ("schemas" ).get ("Organization" ));
76
- //System.out.println(new KubernetesSerialization().unmarshal(schemas).getClass());
77
- System .err .println (jsonAsYaml );
78
- JsonNode schema = jsonNodeTree .get ("components" ).get ("schemas" ).get ("Organization" );
79
-
80
-
81
-
82
- JSONSchemaPropsBuilder specBuilder = new JSONSchemaPropsBuilder ().withType ("object" );
83
- schema .get ("properties" ).fields ().forEachRemaining (
84
- f -> specBuilder .addToProperties (f .getKey (), new JSONSchemaPropsBuilder ().withType (f .getValue ().get ("type" ).asText ()).build ())
85
- );
86
-
87
- CustomResourceDefinitionBuilder defBuilder = new CustomResourceDefinitionBuilder ();
88
- CustomResourceDefinition customResourceDefinition = defBuilder .editOrNewMetadata ()
89
- .withName ("Organization" )
90
- .endMetadata ()
91
- .editOrNewSpec ()
92
- .withGroup ("opgen.io" )
93
- .withNewNames ().withKind ("Organization" ).endNames ()
94
- .withScope ("Namespaced" )
95
- .withVersions (new CustomResourceDefinitionVersionBuilder ()
96
- .withName ("v1alpha1" )
97
- .withServed (true )
98
- .withStorage (true )
99
- .withNewSchema ()
100
- .editOrNewOpenAPIV3Schema ()
101
- .addToProperties ("status" , new JSONSchemaPropsBuilder ().withType ("object" ).build ())
102
- .addToProperties ("spec" , specBuilder .build ())
103
- .endOpenAPIV3Schema ()
104
- .and ()
105
- .build ())
106
- .endSpec ()
107
- .build ();
108
-
109
- String myPodAsYaml = Serialization .asYaml (customResourceDefinition );
110
- System .out .println (myPodAsYaml );
111
- } catch (IOException e1 ) {
112
- // TODO Auto-generated catch block
113
- e1 .printStackTrace ();
114
- }
115
- }
116
57
117
58
@ ParameterizedTest
118
59
@ MethodSource ("responseTypesWithGetById" )
@@ -130,7 +71,7 @@ void getByIdPath(String modelName) {
130
71
}
131
72
132
73
@ ParameterizedTest
133
- @ MethodSource ("modelsToTest " )
74
+ @ MethodSource ("responseTypesWithDelete " )
134
75
void deletePath (String modelName ) {
135
76
ResponseTypeMapper analyzer = new ResponseTypeMapper (model , modelName );
136
77
if (!analyzer .isArrayType ()) {
@@ -156,7 +97,7 @@ void patchPath(String modelName) {
156
97
}
157
98
158
99
@ ParameterizedTest
159
- @ MethodSource ("modelsToTest " )
100
+ @ MethodSource ("responseTypesWithCreate " )
160
101
void createPath (String modelName ) {
161
102
ResponseTypeMapper analyzer = new ResponseTypeMapper (model , modelName );
162
103
if (!analyzer .isArrayType ()) {
@@ -186,27 +127,133 @@ private static Stream<String> responseTypesWithGetById() {
186
127
}
187
128
188
129
private static Stream <String > responseTypesWithPatch () {
189
- Set <String > noFindById = new HashSet <String >(EXCLUDED_RESPONSES );
190
- noFindById .add ("AccessToken" /* AccessToken cannot be patched */ );
191
- noFindById .add ("ActivityPub" /* The post method has additional /index which is not expected */ );
192
- noFindById .add ("AnnotatedTag" /* AnnotatedTag cannot be patched */ );
193
- noFindById .add ("Branch" /* Branch cannot be patched */ );
194
- noFindById .add ("CombinedStatus" /* CombinedStatus is read-only */ );
195
- noFindById .add ("Commit" /* Commit is read-only */ );
196
- noFindById .add ("CommitStatus" /* CommitStatus cannot be patched */ );
197
- noFindById .add ("ContentsResponse" /* ContentsResponse cannot be patched */ );
198
- noFindById .add ("DeployKey" /* DeployKey cannot be patched */ );
199
- noFindById .add ("GPGKey" /* GPGKey cannot be patched */ );
200
-
201
- //TODO Why is patch path for EmailList is /user/settings
202
- //TODO Why is patch path for GPGKeyList is /user/settings
203
-
204
- return reader .getResponseTypeNames (e -> !noFindById .contains (e .getKey ()));
130
+ Set <String > noPatch = new HashSet <String >(EXCLUDED_RESPONSES );
131
+ noPatch .add ("AccessToken" /* AccessToken cannot be patched */ );
132
+ noPatch .add ("ActivityPub" /* ActivityPub cannot be patched */ );
133
+ noPatch .add ("AnnotatedTag" /* AnnotatedTag is read-onlyd */ );
134
+ noPatch .add ("Branch" /* Branch cannot be patched */ );
135
+ noPatch .add ("CombinedStatus" /* CombinedStatus is read-only */ );
136
+ noPatch .add ("Commit" /* Commit is read-only */ );
137
+ noPatch .add ("CommitStatus" /* CommitStatus cannot be patched */ );
138
+ noPatch .add ("ContentsResponse" /* ContentsResponse cannot be patched */ );
139
+ noPatch .add ("DeployKey" /* DeployKey cannot be patched */ );
140
+ noPatch .add ("GPGKey" /* GPGKey cannot be patched */ );
141
+ noPatch .add ("GeneralAPISettings" /* GeneralAPISettings is read-only */ );
142
+ noPatch .add ("GeneralAttachmentSettings" /* GeneralAttachmentSettings is read-only */ );
143
+ noPatch .add ("GeneralRepoSettings" /* GeneralRepoSettings is read-only */ );
144
+ noPatch .add ("GeneralUISettings" /* GeneralUISettings is read-only */ );
145
+ noPatch .add ("GitBlobResponse" /* GitBlobResponse is read-only*/ );
146
+ noPatch .add ("GitTreeResponse" /* GitTreeResponse is read-only */ );
147
+ noPatch .add ("GitignoreTemplateInfo" /* GitignoreTemplateInfo is read-only */ );
148
+ noPatch .add ("IssueDeadline" /* Issue deadline can only be created */ );
149
+ noPatch .add ("LanguageStatistics" /* LanguageStatistics is read-only */ );
150
+ noPatch .add ("LicenseTemplateInfo" /* LicenseTemplateInfo can only be get by id */ );
151
+ noPatch .add ("MarkdownRender" /* MarkdownRender can only be created */ );
152
+ noPatch .add ("MarkupRender" /* MarkupRender can only be created */ );
153
+ noPatch .add ("NodeInfo" /* NodeInfo is read-only */ );
154
+ noPatch .add ("Note" /* Note is read-only */ );
155
+ noPatch .add ("NotificationCount" /* Note is read-only */ );
156
+ noPatch .add ("OrganizationPermissions" /* OrganizationPermissions is read-only */ );
157
+ noPatch .add ("Package" /* Package cannot be patched */ );
158
+ noPatch .add ("PublicKey" /* PublicKey cannot be patched */ );
159
+ noPatch .add ("PullReview" /* PullReview cannot be patched */ );
160
+ noPatch .add ("PullReviewComment" /* PullReviewComment is read-only */ );
161
+ noPatch .add ("PushMirror" /* PushMirror cannot be patched */ );
162
+ noPatch .add ("Reaction" /* Reaction cannot be patched */ );
163
+ noPatch .add ("Reference" /* Reaction cannot be patched */ );
164
+ noPatch .add ("RepoCollaboratorPermission" /* RepoCollaboratorPermission is read-only */ );
165
+ noPatch .add ("RepoIssueConfig" /* RepoIssueConfig is read-only */ );
166
+ noPatch .add ("RepoIssueConfigValidation" /* RepoIssueConfigValidation is read-only */ );
167
+ noPatch .add ("RepoNewIssuePinsAllowed" /* RepoNewIssuePinsAllowed is read-only */ );
168
+ noPatch .add ("SearchResults" /* SearchResults is read-only */ );
169
+ noPatch .add ("Secret" /* Secret can only be created */ );
170
+ noPatch .add ("ServerVersion" /* ServerVersion is read-only */ );
171
+ noPatch .add ("StopWatch" /* StopWatch is read-only */ );
172
+ noPatch .add ("Tag" /* Tag cannot be patched */ );
173
+ noPatch .add ("TopicNames" /* TODO TopicNames cannot be patched but updated!! */ );
174
+ noPatch .add ("TrackedTime" /* TrackedTime is read-only */ );
175
+ noPatch .add ("WatchInfo" /* WatchInfo is read-only */ );
176
+ noPatch .add ("WikiCommitList" /* WikiCommitList is read-only */ );
177
+ return reader .getResponseTypeNames (e -> !noPatch .contains (e .getKey ()));
205
178
}
206
179
207
- private static Stream <String > modelsToTest () {
208
- return reader .getResponseTypeNames (e -> !EXCLUDED_RESPONSES .contains (e .getKey ()));
180
+ private static Stream <String > responseTypesWithCreate () {
181
+ Set <String > noCreate = new HashSet <String >(EXCLUDED_RESPONSES );
182
+ noCreate .add ("ActivityPub" /* The post method has additional /inbox which is not expected */ );
183
+ noCreate .add ("AnnotatedTag" /* AnnotatedTag is read-only */ );
184
+ noCreate .add ("CombinedStatus" /* CombinedStatus is read-only */ );
185
+ noCreate .add ("Commit" /* Commit is read-only */ );
186
+ noCreate .add ("GeneralAPISettings" /* GeneralAPISettings is read-only */ );
187
+ noCreate .add ("GeneralAttachmentSettings" /* GeneralAttachmentSettings is read-only */ );
188
+ noCreate .add ("GeneralRepoSettings" /* GeneralRepoSettings is read-only */ );
189
+ noCreate .add ("GeneralUISettings" /* GeneralUISettings is read-only */ );
190
+ noCreate .add ("GitBlobResponse" /* GitBlobResponse is read-only*/ );
191
+ noCreate .add ("GitHook" /*TODO The get method is in /git and the post one level above */ );
192
+ noCreate .add ("GitTreeResponse" /* GitTreeResponse is read-only */ );
193
+ noCreate .add ("GitignoreTemplateInfo" /* GitignoreTemplateInfo is read-only */ );
194
+ noCreate .add ("LanguageStatistics" /* LanguageStatistics is read-only */ );
195
+ noCreate .add ("LicenseTemplateInfo" /* LicenseTemplateInfo can only be get by id */ );
196
+ noCreate .add ("MarkdownRender" /* TODO MarkdownRender schema is text/html, we don't support this currently*/ );
197
+ noCreate .add ("MarkupRender" /* MarkupRender schema is text/html, we don't support this currently */ );
198
+ noCreate .add ("NodeInfo" /* NodeInfo is read-only */ );
199
+ noCreate .add ("Note" /* Note is read-only */ );
200
+ noCreate .add ("NotificationCount" /* Note is read-only */ );
201
+ noCreate .add ("NotificationThread" /* NotificationThread cannot be created */ );
202
+ noCreate .add ("OrganizationPermissions" /* OrganizationPermissions is read-only */ );
203
+ noCreate .add ("Package" /* Package cannot be created */ );
204
+ noCreate .add ("PullReviewComment" /* PullReviewComment is read-only */ );
205
+ noCreate .add ("Reference" /* Reference cannot be created is only part of ReferenceList */ );
206
+ noCreate .add ("RepoCollaboratorPermission" /* RepoCollaboratorPermission is read-only */ );
207
+ noCreate .add ("RepoIssueConfig" /* RepoIssueConfig is read-only */ );
208
+ noCreate .add ("RepoIssueConfigValidation" /* RepoIssueConfigValidation is read-only */ );
209
+ noCreate .add ("RepoNewIssuePinsAllowed" /* RepoNewIssuePinsAllowed is read-only */ );
210
+ noCreate .add ("SearchResults" /* SearchResults is read-only */ );
211
+ noCreate .add ("Secret" /* Secret can only be created */ );
212
+ noCreate .add ("ServerVersion" /* ServerVersion is read-only */ );
213
+ noCreate .add ("StopWatch" /* StopWatch is read-only */ );
214
+ noCreate .add ("TopicNames" /* TopicNames cannot be created but updated */ );
215
+ noCreate .add ("WatchInfo" /* WatchInfo is read-only */ );
216
+ noCreate .add ("WikiCommitList" /* WikiCommitList is read-only */ );
217
+ return reader .getResponseTypeNames (e -> !noCreate .contains (e .getKey ()));
209
218
}
210
219
220
+ private static Stream <String > responseTypesWithDelete () {
221
+ Set <String > noDelete = new HashSet <String >(EXCLUDED_RESPONSES );
222
+ noDelete .add ("ActivityPub" /* ActivityPub cannot be deleted */ );
223
+ noDelete .add ("AnnotatedTag" /* AnnotatedTag is read-only */ );
224
+ noDelete .add ("CombinedStatus" /* CombinedStatus is read-only */ );
225
+ noDelete .add ("Commit" /* Commit is read-only */ );
226
+ noDelete .add ("CommitStatus" /* CommitStatus cannot be deleted */ );
227
+ noDelete .add ("GeneralAPISettings" /* GeneralAPISettings is read-only */ );
228
+ noDelete .add ("GeneralAttachmentSettings" /* GeneralAttachmentSettings is read-only */ );
229
+ noDelete .add ("GeneralRepoSettings" /* GeneralRepoSettings is read-only */ );
230
+ noDelete .add ("GeneralUISettings" /* GeneralUISettings is read-only */ );
231
+ noDelete .add ("GitBlobResponse" /* GitBlobResponse is read-only*/ );
232
+ noDelete .add ("GitTreeResponse" /* GitTreeResponse is read-only */ );
233
+ noDelete .add ("GitignoreTemplateInfo" /* GitignoreTemplateInfo is read-only */ );
234
+ noDelete .add ("IssueDeadline" /* Issue deadline can only be created */ );
235
+ noDelete .add ("LanguageStatistics" /* LanguageStatistics is read-only */ );
236
+ noDelete .add ("LicenseTemplateInfo" /* LicenseTemplateInfo can only be get by id */ );
237
+ noDelete .add ("MarkdownRender" /* TODO MarkdownRender schema is text/html, we don't support this currently*/ );
238
+ noDelete .add ("MarkupRender" /* MarkupRender schema is text/html, we don't support this currently */ );
239
+ noDelete .add ("NodeInfo" /* NodeInfo is read-only */ );
240
+ noDelete .add ("Note" /* Note is read-only */ );
241
+ noDelete .add ("NotificationCount" /* Note is read-only */ );
242
+ noDelete .add ("NotificationThread" /* NotificationThread cannot be created */ );
243
+ noDelete .add ("OrganizationPermissions" /* OrganizationPermissions is read-only */ );
244
+ noDelete .add ("PullReviewComment" /* PullReviewComment is read-only */ );
245
+ noDelete .add ("Reference" /* Reference cannot be deleted */ );
246
+ noDelete .add ("RepoCollaboratorPermission" /* RepoCollaboratorPermission is read-only */ );
247
+ noDelete .add ("RepoIssueConfig" /* RepoIssueConfig is read-only */ );
248
+ noDelete .add ("RepoIssueConfigValidation" /* RepoIssueConfigValidation is read-only */ );
249
+ noDelete .add ("RepoNewIssuePinsAllowed" /* RepoNewIssuePinsAllowed is read-only */ );
250
+ noDelete .add ("SearchResults" /* SearchResults is read-only */ );
251
+ noDelete .add ("Secret" /* Secret can only be created */ );
252
+ noDelete .add ("ServerVersion" /* ServerVersion is read-only */ );
253
+ noDelete .add ("StopWatch" /* StopWatch is read-only */ );
254
+ noDelete .add ("TopicNames" /* TODOTopicNames have no findById but only list. Hence it cannot be found. */ );
255
+ noDelete .add ("WikiCommitList" /* WikiCommitList is read-only */ );
256
+ return reader .getResponseTypeNames (e -> !noDelete .contains (e .getKey ()));
257
+ }
211
258
212
259
}
0 commit comments