summaryrefslogtreecommitdiffstats
path: root/php-swaggest-json-schema.spec
blob: 76ef96de580fa202b58de98f45268fb659c06140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# remirepo/fedora spec file for php-swaggest-json-schema
#
# Copyright (c) 2019-2021 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%bcond_without       tests

# Github
%global gh_commit    d0126bd830c92a498691d278f01d3ce13a2c9c0a
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     swaggest
%global gh_project   php-json-schema
# Packagist
%global pk_vendor    %{gh_owner}
%global pk_project   json-schema
# Namespace
%global ns_vendor    Swaggest
%global ns_project   JsonSchema
%global major        %nil

Name:           php-%{pk_vendor}-%{pk_project}%{major}
Version:        0.12.35
Release:        1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist}
Summary:        High definition PHP structures with JSON-schema based validation

License:        MIT
URL:            https://github.com/%{gh_owner}/%{gh_project}
Source0:        %{name}-%{version}-%{?gh_short}.tgz
Source1:        makesrc.sh

BuildArch:      noarch
%if %{with tests}
BuildRequires:  php(language) >= 5.4
BuildRequires:  php-json
BuildRequires:  php-mbstring
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(phplang/scope-exit)    >= 1.0   with php-composer(phplang/scope-exit)    < 2)
BuildRequires: (php-composer(swaggest/json-diff)    >= 3.5.1 with php-composer(swaggest/json-diff)    < 4)
%else
BuildRequires:  php-phplang-scope-exit              >= 1.0
BuildRequires:  php-swaggest-json-diff              >= 3.5.1
%endif
# For tests, from composer.json "require-dev": {
#    "phpunit/phpunit": "^5",
#    "phpunit/php-code-coverage": "^4",
#    "codeclimate/php-test-reporter": "^0.4.0"
BuildRequires:  php-composer(phpunit/phpunit) >= 5
%global phpunit %{_bindir}/phpunit
BuildRequires:  php-date
BuildRequires:  php-filter
BuildRequires:  php-pcre
BuildRequires:  php-spl
# For autoloader
BuildRequires:  php-fedora-autoloader-devel
%endif

# From composer.json, "require": {
#    "php": ">=5.4",
#    "ext-json": "*",
#    "ext-mbstring": "*",
#    "phplang/scope-exit": "^1.0",
#    "swaggest/json-diff": "^3.5.1"
Requires:       php(language) >= 5.4
Requires:       php-json
Requires:       php-mbstring
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(phplang/scope-exit)    >= 1.0   with php-composer(phplang/scope-exit)    < 2)
Requires:      (php-composer(swaggest/json-diff)    >= 3.5.1 with php-composer(swaggest/json-diff)    < 4)
%else
Requires:       php-phplang-scope-exit              >= 1.0
Requires:       php-swaggest-json-diff              >= 3.5.1
%endif
# From phpcompatinfo report for 0.12.17
Requires:       php-date
Requires:       php-filter
Requires:       php-pcre
Requires:       php-spl
# For generated autoloader
Requires:       php-composer(fedora/autoloader)

# Composer
Provides:       php-composer(%{pk_vendor}/%{pk_project}) = %{version}


%description
High definition PHP structures with JSON-schema based validation.

Autoloader: %{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php


%prep
%setup -q -n %{gh_project}-%{gh_commit}

: Fix layout
mkdir src/spec
cp -p spec/*.json src/spec/
sed -e 's:/../spec/:/spec/:' -i src/RemoteRef/Preloaded.php


%build
: Create autoloader
%{_bindir}/phpab -t fedora -o src/autoload.php src
cat << 'EOF' | tee -a src/autoload.php

\Fedora\Autoloader\Dependencies::required([
    '%{_datadir}/php/PhpLang/scope-exit-autoload.php',
    '%{_datadir}/php/Swaggest/JsonDiff/autoload.php',
]);
EOF


%install
: Library
mkdir -p         %{buildroot}%{_datadir}/php/%{ns_vendor}
cp -pr src       %{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}


%check
%if %{with tests}
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require '%{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\%{ns_project}\\Tests\\', dirname(__DIR__).'/tests/src');
EOF

# Skip online tests: testInvalid, testValidate
ret=0
for cmd in php php73 php74 php80; do
   if which $cmd; then
      $cmd %{phpunit} \
        --no-coverage \
        --filter '^((?!(SwaggerTest::testInvalid|SwaggerTest::testValidate)).)*$' \
        --verbose || ret=1
   fi
done
exit $ret
%else
: Test suite disabled
%endif


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc composer.json
%doc README.md
%doc CHANGELOG.md
%{_datadir}/php/%{ns_vendor}/%{ns_project}%{major}


%changelog
* Fri Jun 18 2021 Remi Collet <remi@remirepo.net> - 0.12.35-1
- update to 0.12.35

* Thu Jun 17 2021 Remi Collet <remi@remirepo.net> - 0.12.34-1
- update to 0.12.34

* Mon May 31 2021 Remi Collet <remi@remirepo.net> - 0.12.33-1
- update to 0.12.33

* Mon May 17 2021 Remi Collet <remi@remirepo.net> - 0.12.32-1
- update to 0.12.32

* Mon Sep 21 2020 Remi Collet <remi@remirepo.net> - 0.12.31-1
- update to 0.12.31

* Thu Sep 10 2020 Remi Collet <remi@remirepo.net> - 0.12.30-1
- update to 0.12.30

* Thu Mar 19 2020 Remi Collet <remi@remirepo.net> - 0.12.29-1
- update to 0.12.29

* Mon Jan 27 2020 Remi Collet <remi@remirepo.net> - 0.12.28-1
- update to 0.12.28
- drop patch merged upstream

* Mon Jan 27 2020 Remi Collet <remi@remirepo.net> - 0.12.27-1
- update to 0.12.27
- add patch for PHP 7.4 from
  https://github.com/swaggest/php-json-schema/pull/101

* Tue Jan  7 2020 Remi Collet <remi@remirepo.net> - 0.12.25-1
- update to 0.12.25

* Wed Dec  4 2019 Remi Collet <remi@remirepo.net> - 0.12.24-1
- update to 0.12.24

* Tue Dec  3 2019 Remi Collet <remi@remirepo.net> - 0.12.23-1
- update to 0.12.23

* Tue Oct 22 2019 Remi Collet <remi@remirepo.net> - 0.12.22-1
- update to 0.12.22

* Wed Oct  2 2019 Remi Collet <remi@remirepo.net> - 0.12.21-1
- update to 0.12.21

* Mon Sep 23 2019 Remi Collet <remi@remirepo.net> - 0.12.20-1
- update to 0.12.20

* Tue Sep 17 2019 Remi Collet <remi@remirepo.net> - 0.12.19-1
- update to 0.12.19

* Thu Sep 12 2019 Remi Collet <remi@remirepo.net> - 0.12.17-1
- initial package