@@ -824,4 +824,106 @@ public function testNormalizeWithoutPrefix(): void
824
824
825
825
$ this ->assertEquals ($ expected , $ documentationNormalizer ->normalize ($ documentation , null , [ContextBuilder::HYDRA_CONTEXT_HAS_PREFIX => false ]));
826
826
}
827
+
828
+ public function testNormalizeNoEntrypointAndHideHydraOperation (): void
829
+ {
830
+ $ title = 'Test Api ' ;
831
+ $ desc = 'test ApiGerard ' ;
832
+ $ version = '0.0.0 ' ;
833
+ $ documentation = new Documentation (new ResourceNameCollection (['dummy ' => 'dummy ' ]), $ title , $ desc , $ version );
834
+
835
+ $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataCollectionFactoryInterface::class);
836
+ $ resourceMetadataFactoryProphecy ->create ('dummy ' )->willReturn (new ResourceMetadataCollection ('dummy ' , [
837
+ ((new ApiResource ())->withHideHydraOperation (true ))->withOperations (new Operations ([
838
+ 'get ' => new Get (),
839
+ ])),
840
+ ]));
841
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
842
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
843
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
844
+ $ urlGenerator = $ this ->prophesize (UrlGeneratorInterface::class);
845
+ $ urlGenerator ->generate ('api_doc ' , ['_format ' => 'jsonld ' ], Argument::any ())->willReturn ('/doc ' );
846
+
847
+ $ documentationNormalizer = new DocumentationNormalizer (
848
+ $ resourceMetadataFactoryProphecy ->reveal (),
849
+ $ propertyNameCollectionFactoryProphecy ->reveal (),
850
+ $ propertyMetadataFactoryProphecy ->reveal (),
851
+ $ resourceClassResolverProphecy ->reveal (),
852
+ $ urlGenerator ->reveal (),
853
+ new CustomConverter (),
854
+ [],
855
+ false ,
856
+ );
857
+
858
+ $ expected = [
859
+ '@context ' => [
860
+ HYDRA_CONTEXT ,
861
+ [
862
+ '@vocab ' => '/doc# ' ,
863
+ 'hydra ' => 'http://www.w3.org/ns/hydra/core# ' ,
864
+ 'rdf ' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns# ' ,
865
+ 'rdfs ' => 'http://www.w3.org/2000/01/rdf-schema# ' ,
866
+ 'xmls ' => 'http://www.w3.org/2001/XMLSchema# ' ,
867
+ 'owl ' => 'http://www.w3.org/2002/07/owl# ' ,
868
+ 'schema ' => 'https://schema.org/ ' ,
869
+ 'domain ' => [
870
+ '@id ' => 'rdfs:domain ' ,
871
+ '@type ' => '@id ' ,
872
+ ],
873
+ 'range ' => [
874
+ '@id ' => 'rdfs:range ' ,
875
+ '@type ' => '@id ' ,
876
+ ],
877
+ 'subClassOf ' => [
878
+ '@id ' => 'rdfs:subClassOf ' ,
879
+ '@type ' => '@id ' ,
880
+ ],
881
+ ],
882
+ ],
883
+ '@id ' => '/doc ' ,
884
+ '@type ' => 'ApiDocumentation ' ,
885
+ 'title ' => 'Test Api ' ,
886
+ 'description ' => 'test ApiGerard ' ,
887
+ 'supportedClass ' => [
888
+ [
889
+ '@id ' => '#ConstraintViolationList ' ,
890
+ '@type ' => 'Class ' ,
891
+ 'title ' => 'ConstraintViolationList ' ,
892
+ 'description ' => 'A constraint violation List. ' ,
893
+ 'supportedProperty ' => [
894
+ [
895
+ '@type ' => 'SupportedProperty ' ,
896
+ 'property ' => [
897
+ '@id ' => '#ConstraintViolationList/propertyPath ' ,
898
+ '@type ' => 'rdf:Property ' ,
899
+ 'rdfs:label ' => 'propertyPath ' ,
900
+ 'domain ' => '#ConstraintViolationList ' ,
901
+ 'range ' => 'xmls:string ' ,
902
+ ],
903
+ 'title ' => 'propertyPath ' ,
904
+ 'description ' => 'The property path of the violation ' ,
905
+ 'readable ' => true ,
906
+ 'writeable ' => false ,
907
+ ],
908
+ [
909
+ '@type ' => 'SupportedProperty ' ,
910
+ 'property ' => [
911
+ '@id ' => '#ConstraintViolationList/message ' ,
912
+ '@type ' => 'rdf:Property ' ,
913
+ 'rdfs:label ' => 'message ' ,
914
+ 'domain ' => '#ConstraintViolationList ' ,
915
+ 'range ' => 'xmls:string ' ,
916
+ ],
917
+ 'title ' => 'message ' ,
918
+ 'description ' => 'The message associated with the violation ' ,
919
+ 'readable ' => true ,
920
+ 'writeable ' => false ,
921
+ ],
922
+ ],
923
+ ],
924
+ ],
925
+ ];
926
+
927
+ $ this ->assertEquals ($ expected , $ documentationNormalizer ->normalize ($ documentation , null , [ContextBuilder::HYDRA_CONTEXT_HAS_PREFIX => false ]));
928
+ }
827
929
}
0 commit comments