Complete package for generating ocds structs (with extensions) in golang
This commit is contained in:
1 parent
da726550d4
commit
35974fa070
47 files changed
+9826
-264
No files matched your search
@@ -25,3 +25,11 @@ go.work.sum
|
|||||||
# env file
|
# env file
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode/*
|
||||||
|
|
||||||
|
# Build directory
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Release directory
|
||||||
|
release/
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"version": "2",
|
||||||
|
"run": {
|
||||||
|
"timeout": "5m",
|
||||||
|
"tests": true
|
||||||
|
},
|
||||||
|
"linters": {
|
||||||
|
"enable": [
|
||||||
|
"cyclop",
|
||||||
|
"dogsled",
|
||||||
|
"errcheck",
|
||||||
|
"godox",
|
||||||
|
"govet",
|
||||||
|
"gosec",
|
||||||
|
"ineffassign",
|
||||||
|
"nilerr",
|
||||||
|
"nilnil",
|
||||||
|
"nolintlint",
|
||||||
|
"unused",
|
||||||
|
"whitespace"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"formatters": {
|
||||||
|
"enable": [
|
||||||
|
"gci",
|
||||||
|
"gofmt",
|
||||||
|
"goimports",
|
||||||
|
"golines"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"golines": {
|
||||||
|
"max-len": 100,
|
||||||
|
"tab-len": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"max-same-issues": 0,
|
||||||
|
"max-issues-per-linter": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,303 +2,164 @@ GNU LESSER GENERAL PUBLIC LICENSE
|
|||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
0. Additional Definitions.
|
0. Additional Definitions.
|
||||||
|
|
||||||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
1. Exception to Section 3 of the GNU GPL.
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
2. Conveying Modified Versions.
|
2. Conveying Modified Versions.
|
||||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
|
||||||
|
|
||||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
3. Object Code Incorporating Material from Library Header Files.
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
4. Combined Works.
|
4. Combined Works.
|
||||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
d) Do one of the following:
|
d) Do one of the following:
|
||||||
|
|
||||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
5. Combined Libraries.
|
5. Combined Libraries.
|
||||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
6. Revised Versions of the GNU Lesser General Public License.
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
|
versions will be similar in spirit to the present version, but may
|
||||||
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
Each version is given a distinguishing version number. If the
|
||||||
Version 3, 29 June 2007
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
Preamble
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
||||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
“This License” refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
|
||||||
|
|
||||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
|
||||||
|
|
||||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
|
||||||
|
|
||||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
|
||||||
|
|
||||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
|
||||||
|
|
||||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
|
||||||
|
|
||||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
|
||||||
|
|
||||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
|
||||||
|
|
||||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
|
||||||
|
|
||||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
go-ocds
|
|
||||||
Copyright (C) 2026 Go
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
go-ocds Copyright (C) 2026 Go
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
@@ -1,2 +1,85 @@
|
|||||||
# go-ocds
|
# go-ocds (ocdsgen)
|
||||||
|
|
||||||
|
OCDS 1.1 types for Go, with extensions chosen per package.
|
||||||
|
|
||||||
|
The module contains a generator and some ready-made profiles:
|
||||||
|
|
||||||
|
cmd/ocdsgen/ CLI entry point (Cobra)
|
||||||
|
internal/cli/ command definitions: generate, resolve, schema
|
||||||
|
internal/generator/ fetch, resolve, merge and emit (no CLI code)
|
||||||
|
profiles/core/ no extensions
|
||||||
|
profiles/eu/ EU profile
|
||||||
|
profiles/uk/ UK extension to the EU profile
|
||||||
|
profiles/findTender/ UK gov Find A Tender service profile with extensions
|
||||||
|
example/ a consumer module generating its own packages
|
||||||
|
|
||||||
|
Every generated package is self-contained: it imports only the standard
|
||||||
|
library, so a package's types depend only on its own extensions.json.
|
||||||
|
|
||||||
|
## Use a ready-made profile
|
||||||
|
|
||||||
|
go get git.avsdev.uk/Go/go-ocds@v1.0.0
|
||||||
|
|
||||||
|
import "git.avsdev.uk/Go/go-ocds/profiles/uk"
|
||||||
|
var r uk.Release
|
||||||
|
|
||||||
|
## Generate your own packages
|
||||||
|
|
||||||
|
Give each package its own `extensions.json` and a directive:
|
||||||
|
|
||||||
|
//go:generate go tool ocdsgen generate -c extensions.json -o ocds_gen.go -p tenders
|
||||||
|
|
||||||
|
Pin the generator in your go.mod (Go 1.24+):
|
||||||
|
|
||||||
|
go get -tool git.avsdev.uk/Go/go-ocds/cmd/ocdsgen@v1.0.0
|
||||||
|
|
||||||
|
On older Go, add a `tools.go` with a blank import of
|
||||||
|
`git.avsdev.uk/Go/go-ocds/cmd/ocdsgen` behind `//go:build tools`, and use
|
||||||
|
`go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen` in the directive
|
||||||
|
(see example/).
|
||||||
|
|
||||||
|
Then `go generate ./...` and commit the generated `ocds_gen.go` files.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
ocdsgen generate [-c extensions.json] [-o ocds_gen.go] [-p name] [--check]
|
||||||
|
ocdsgen resolve [-c extensions.json] [--json]
|
||||||
|
ocdsgen schema [-c extensions.json] [--kind release|package] [-o file]
|
||||||
|
|
||||||
|
Global flags: `--strict` fails on any warning, `-q/--quiet` hides notes and
|
||||||
|
warnings, `--timeout` sets the per-request HTTP timeout. Run
|
||||||
|
`ocdsgen <command> --help` for details.
|
||||||
|
|
||||||
|
- `generate` writes the Go types. `-p` defaults to the output directory's
|
||||||
|
name. `-o -` writes to stdout. `--check` writes nothing and fails if the
|
||||||
|
file is missing or stale, for CI: `ocdsgen generate --check --strict`.
|
||||||
|
- `resolve` lists every extension the config pulls in, dependencies first,
|
||||||
|
in the order their patches are applied.
|
||||||
|
- `schema` writes the merged JSON Schema the types are generated from, for
|
||||||
|
debugging a config or validating data with other tools.
|
||||||
|
|
||||||
|
Paths in a config that aren't URLs are resolved relative to the config file,
|
||||||
|
so a project can keep private or vendored extensions alongside it.
|
||||||
|
|
||||||
|
## Adding a profile to this module
|
||||||
|
|
||||||
|
Create `profiles/<name>/` with `extensions.json` and a `generate.go` like the
|
||||||
|
existing ones, run `go generate ./...`, and tag a release.
|
||||||
|
|
||||||
|
## Generator warnings
|
||||||
|
|
||||||
|
- two extensions give the same field different types (the later one wins);
|
||||||
|
- the same extension repo is included at two versions;
|
||||||
|
- a definition is never referenced, which usually means an extension patches
|
||||||
|
a type (e.g. `Lot`) whose defining extension (e.g. Lots) isn't in the config.
|
||||||
|
|
||||||
|
## Type mapping
|
||||||
|
|
||||||
|
- `date-time` → `*time.Time`,
|
||||||
|
- `integer` → `*int`,
|
||||||
|
- `number` → `*float64`,
|
||||||
|
- `boolean` → `*bool`,
|
||||||
|
- `["string","integer"]` → `ID`,
|
||||||
|
- objects without properties → `map[string]any`,
|
||||||
|
- anything ambiguous → `json.RawMessage`.
|
||||||
|
- All non-required fields are `omitempty`.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// Command ocdsgen generates Go types for OCDS releases with a chosen set of
|
||||||
|
// extensions applied. Run `ocdsgen --help` for usage.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"git.avsdev.uk/Go/go-ocds/internal/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := cli.NewRootCmd().Execute(); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, "ocdsgen:", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
module example.com/myapp
|
||||||
|
|
||||||
|
go 1.22
|
||||||
|
|
||||||
|
require git.avsdev.uk/Go/go-ocds v0.0.0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
github.com/spf13/cobra v1.10.2 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.9 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
// For this example only: use the copy of the module in the parent directory.
|
||||||
|
// In a real project, delete this line and `go get git.avsdev.uk/Go/go-ocds@v1.x.y`.
|
||||||
|
replace git.avsdev.uk/Go/go-ocds => ../
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||||
|
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||||
|
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
|
||||||
|
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": [
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_budget_breakdown_extension/master/extension.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Package budgets holds OCDS types generated with the extensions in extensions.json.
|
||||||
|
package budgets
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p budgets
|
||||||
@@ -0,0 +1,665 @@
|
|||||||
|
// Code generated by ocdsgen from extensions.json. DO NOT EDIT.
|
||||||
|
|
||||||
|
// Package budgets contains Go types for OCDS releases with these extensions applied
|
||||||
|
// (dependencies first, in the order their patches were merged):
|
||||||
|
//
|
||||||
|
// - Budget Breakdown (declared)
|
||||||
|
// https://raw.githubusercontent.com/open-contracting-extensions/ocds_budget_breakdown_extension/master/extension.json
|
||||||
|
package budgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeclaredExtensions are the extension URLs to list in ReleasePackage.Extensions.
|
||||||
|
var DeclaredExtensions = []string{
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_budget_breakdown_extension/master/extension.json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleasePackage: The release package contains a list of releases along with some publishing
|
||||||
|
// metadata.
|
||||||
|
type ReleasePackage struct {
|
||||||
|
// The URI of this package that identifies it uniquely in the world.
|
||||||
|
URI string `json:"uri"`
|
||||||
|
// The version of the OCDS schema used in this package, expressed as major.minor For example:
|
||||||
|
// 1.0 or 1.1
|
||||||
|
Version string `json:"version"`
|
||||||
|
// An array of OCDS extensions used in this package, in which each array item is the URL of an
|
||||||
|
// extension.json file.
|
||||||
|
Extensions []string `json:"extensions,omitempty"`
|
||||||
|
// The date that this package was published.
|
||||||
|
PublishedDate time.Time `json:"publishedDate"`
|
||||||
|
// An array of one or more OCDS releases.
|
||||||
|
Releases []Release `json:"releases"`
|
||||||
|
// Information to uniquely identify the publisher of this package.
|
||||||
|
Publisher *ReleasePackagePublisher `json:"publisher"`
|
||||||
|
// A link to the license that applies to the data in this package.
|
||||||
|
License string `json:"license,omitempty"`
|
||||||
|
// A link to a document describing the publishers [publication
|
||||||
|
// policy](https://standard.open-contracting.org/{{version}}/{{lang}}/guidance/publish/#finalize-your-publication-policy).
|
||||||
|
PublicationPolicy string `json:"publicationPolicy,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleasePackagePublisher: Information to uniquely identify the publisher of this package.
|
||||||
|
type ReleasePackagePublisher struct {
|
||||||
|
// The name of the organization or department responsible for publishing this data.
|
||||||
|
Name string `json:"name"`
|
||||||
|
// The scheme that holds the unique identifiers used to identify the item being identified.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The unique ID for this entity under the given ID scheme.
|
||||||
|
Uid string `json:"uid,omitempty"`
|
||||||
|
// A URI to identify the publisher.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release: Each release provides data about a single contracting process at a particular
|
||||||
|
// point in time.
|
||||||
|
type Release struct {
|
||||||
|
// A globally unique identifier for this Open Contracting Process.
|
||||||
|
OCID string `json:"ocid"`
|
||||||
|
// An identifier for this particular release of information.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// The date on which the information contained in the release was first recorded in, or
|
||||||
|
// published by, any system.
|
||||||
|
Date time.Time `json:"date"`
|
||||||
|
// One or more values from the closed
|
||||||
|
// [releaseTag](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#release-tag)
|
||||||
|
// codelist. Codelist: releaseTag.csv (closed).
|
||||||
|
Tag []string `json:"tag"`
|
||||||
|
// The type of initiation process used for this contract, from the closed
|
||||||
|
// [initiationType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#initiation-type)
|
||||||
|
// codelist. Codelist: initiationType.csv (closed).
|
||||||
|
InitiationType string `json:"initiationType"`
|
||||||
|
// Information on the parties (organizations, economic operators and other participants) who
|
||||||
|
// are involved in the contracting process and their roles, e.g.
|
||||||
|
Parties []Organization `json:"parties,omitempty"`
|
||||||
|
// A buyer is an entity whose budget will be used to pay for goods, works or services related
|
||||||
|
// to a contract.
|
||||||
|
Buyer *OrganizationReference `json:"buyer,omitempty"`
|
||||||
|
// Information from the planning phase of the contracting process.
|
||||||
|
Planning *Planning `json:"planning,omitempty"`
|
||||||
|
// The activities undertaken in order to enter into a contract.
|
||||||
|
Tender *Tender `json:"tender,omitempty"`
|
||||||
|
// Information from the award phase of the contracting process.
|
||||||
|
Awards []Award `json:"awards,omitempty"`
|
||||||
|
// Information from the contract creation phase of the procurement process.
|
||||||
|
Contracts []Contract `json:"contracts,omitempty"`
|
||||||
|
// The default language of the data using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process follows on from one or more
|
||||||
|
// other processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address: An address.
|
||||||
|
type Address struct {
|
||||||
|
// The street address.
|
||||||
|
StreetAddress string `json:"streetAddress,omitempty"`
|
||||||
|
// The locality.
|
||||||
|
Locality string `json:"locality,omitempty"`
|
||||||
|
// The region.
|
||||||
|
Region string `json:"region,omitempty"`
|
||||||
|
// The postal code.
|
||||||
|
PostalCode string `json:"postalCode,omitempty"`
|
||||||
|
// The country name.
|
||||||
|
CountryName string `json:"countryName,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amendment: Amendment information
|
||||||
|
type Amendment struct {
|
||||||
|
// The date of this amendment.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// An explanation for the amendment.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// An identifier for this amendment: often the amendment number
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// A free text, or semi-structured, description of the changes made in this amendment.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **before** the amendment was made.
|
||||||
|
AmendsReleaseID string `json:"amendsReleaseID,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **after** the amendment was made.
|
||||||
|
ReleaseID string `json:"releaseID,omitempty"`
|
||||||
|
// An array of change objects describing the fields changed, and their former values.
|
||||||
|
// Deprecated: since OCDS 1.1. A free-text or semi-structured string describing the changes
|
||||||
|
// made in each amendment can be provided in the amendment.description field.
|
||||||
|
Changes []AmendmentChanges `json:"changes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AmendmentChanges struct {
|
||||||
|
// The property name that has been changed relative to the place the amendment is.
|
||||||
|
Property string `json:"property,omitempty"`
|
||||||
|
// The previous value of the changed property, in whatever type the property is.
|
||||||
|
FormerValue json.RawMessage `json:"former_value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Award: An award for the given procurement.
|
||||||
|
type Award struct {
|
||||||
|
// The identifier for this award.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Award title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Award description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the award, from the closed
|
||||||
|
// [awardStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-status)
|
||||||
|
// codelist. Codelist: awardStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The date of the contract award.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The total value of this award.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The suppliers awarded this award.
|
||||||
|
Suppliers []OrganizationReference `json:"suppliers,omitempty"`
|
||||||
|
// The goods and services awarded in this award, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The period for which the contract has been awarded.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// All documents and attachments related to the award, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// An award amendment is a formal change to the details of the award, and generally involves
|
||||||
|
// the publication of a new award notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Budget: This section contains information about the budget line, and associated projects,
|
||||||
|
// through which this contracting process is funded.
|
||||||
|
type Budget struct {
|
||||||
|
// An identifier for the budget line item which provides funds for this contracting process.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A short free text description of the budget source.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The value reserved in the budget for this contracting process.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// The name of the project through which this contracting process is funded (if applicable).
|
||||||
|
Project string `json:"project,omitempty"`
|
||||||
|
// An external identifier for the project that this contracting process forms part of, or is
|
||||||
|
// funded via (if applicable).
|
||||||
|
ProjectID ID `json:"projectID,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about the budget line-item or
|
||||||
|
// line-items that fund this contracting process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1) Used to point either to a corresponding Budget Data Package, or to a
|
||||||
|
// machine or human-readable source where users can find further information on the budget
|
||||||
|
// line item identifiers, or project identifiers, provided here.
|
||||||
|
// Deprecated: since OCDS 1.1. The budget data source field was intended to link to
|
||||||
|
// machine-readable data about the budget for a contracting process, but has been widely
|
||||||
|
// mis-used to provide free-text descriptions of budget providers.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
// A detailed breakdown of the budget by period and/or participating funders.
|
||||||
|
BudgetBreakdown []BudgetBreakdown `json:"budgetBreakdown,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BudgetBreakdown: This section allows a detailed budget breakdown to be expressed, covering
|
||||||
|
// multiple budget sources and multiple periods
|
||||||
|
type BudgetBreakdown struct {
|
||||||
|
// An identifier for this particular budget entry.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A short free text description of this budget entry.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The value of the budget line item.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable information about this budget entry.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// The period covered by this budget entry.
|
||||||
|
Period *Period `json:"period,omitempty"`
|
||||||
|
// The organization providing the funds for this budget entry.
|
||||||
|
SourceParty *OrganizationReference `json:"sourceParty,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classification: A classification consists of at least two parts: an identifier for the list
|
||||||
|
// (scheme) from which the classification is taken, and an identifier for the category from
|
||||||
|
// that list being applied.
|
||||||
|
type Classification struct {
|
||||||
|
// The scheme or codelist from which the classification code is taken. Codelist:
|
||||||
|
// itemClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The classification code taken from the scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A textual description or title for the classification code.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A URI to uniquely identify the classification code.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContactPoint: A person, contact point or department to contact in relation to this
|
||||||
|
// contracting process.
|
||||||
|
type ContactPoint struct {
|
||||||
|
// The name of the contact person, department, or contact point, for correspondence relating
|
||||||
|
// to this contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The e-mail address of the contact point/person.
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
// The telephone number of the contact point/person.
|
||||||
|
Telephone string `json:"telephone,omitempty"`
|
||||||
|
// The fax number of the contact point/person.
|
||||||
|
FaxNumber string `json:"faxNumber,omitempty"`
|
||||||
|
// A web address for the contact point/person.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract: Information regarding the signed contract between the buyer and supplier(s).
|
||||||
|
type Contract struct {
|
||||||
|
// The identifier for this contract.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// The award.id against which this contract is being issued.
|
||||||
|
AwardID ID `json:"awardID"`
|
||||||
|
// Contract title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Contract description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the contract, from the closed
|
||||||
|
// [contractStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#contract-status)
|
||||||
|
// codelist. Codelist: contractStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The start and end date for the contract.
|
||||||
|
Period *Period `json:"period,omitempty"`
|
||||||
|
// The total value of this contract.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The goods, services, and any intangible outcomes in this contract.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The date the contract was signed.
|
||||||
|
DateSigned *time.Time `json:"dateSigned,omitempty"`
|
||||||
|
// All documents and attachments related to the contract, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// Information related to the implementation of the contract in accordance with the
|
||||||
|
// obligations laid out therein.
|
||||||
|
Implementation *Implementation `json:"implementation,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process is followed by one or more
|
||||||
|
// contracting processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
// A list of milestones associated with the finalization of this contract.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A contract amendment is a formal change to, or extension of, a contract, and generally
|
||||||
|
// involves the publication of a new contract notice/release, or some other documents
|
||||||
|
// detailing the change.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Document: Links to, or descriptions of, external documents can be attached at various
|
||||||
|
// locations within the standard.
|
||||||
|
type Document struct {
|
||||||
|
// A local, unique identifier for this document.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A classification of the document described, using the open
|
||||||
|
// [documentType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#document-type)
|
||||||
|
// codelist. Codelist: documentType.csv (open).
|
||||||
|
DocumentType string `json:"documentType,omitempty"`
|
||||||
|
// The document title.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A short description of the document.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A direct link to the document or attachment.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
// The date on which the document was first published.
|
||||||
|
DatePublished *time.Time `json:"datePublished,omitempty"`
|
||||||
|
// Date that the document was last modified
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The format of the document, using the open [IANA Media
|
||||||
|
// Types](https://www.iana.org/assignments/media-types/media-types.xhtml) codelist (see the
|
||||||
|
// values in the 'Template' column), or using the 'offline/print' code if the described
|
||||||
|
// document is published offline.
|
||||||
|
Format string `json:"format,omitempty"`
|
||||||
|
// The language of the linked document using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identifier: A unique identifier for a party (organization).
|
||||||
|
type Identifier struct {
|
||||||
|
// Organization identifiers should be taken from an existing organization identifier list.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the organization in the selected scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The legally registered name of the organization.
|
||||||
|
LegalName string `json:"legalName,omitempty"`
|
||||||
|
// A URI to identify the organization, such as those provided by [Open
|
||||||
|
// Corporates](https://opencorporates.com) or some other relevant URI provider.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementation: Information during the performance / implementation stage of the contract.
|
||||||
|
type Implementation struct {
|
||||||
|
// A list of the spending transactions made against this contract
|
||||||
|
Transactions []Transaction `json:"transactions,omitempty"`
|
||||||
|
// As milestones are completed, the milestone's status and dates should be updated.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// Documents and reports that are part of the implementation phase e.g.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Item: A good, service, or work to be contracted.
|
||||||
|
type Item struct {
|
||||||
|
// A local identifier to reference and merge the items by.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A description of the goods, services to be provided.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The primary classification for the item.
|
||||||
|
Classification *Classification `json:"classification,omitempty"`
|
||||||
|
// An array of additional classifications for the item.
|
||||||
|
AdditionalClassifications []Classification `json:"additionalClassifications,omitempty"`
|
||||||
|
// The number of units to be provided.
|
||||||
|
Quantity *float64 `json:"quantity,omitempty"`
|
||||||
|
// A description of the unit in which the supplies, services or works are provided (e.g.
|
||||||
|
Unit *ItemUnit `json:"unit,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemUnit: A description of the unit in which the supplies, services or works are provided
|
||||||
|
// (e.g.
|
||||||
|
type ItemUnit struct {
|
||||||
|
// The list from which identifiers for units of measure are taken, using the open
|
||||||
|
// [unitClassificationScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#unit-classification-scheme)
|
||||||
|
// codelist. Codelist: unitClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier from the codelist referenced in the `scheme` field.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// Name of the unit.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The monetary value of a single unit.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The machine-readable URI for the unit of measure, provided by the scheme.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Milestone: The milestone block can be used to represent a wide variety of events in the
|
||||||
|
// lifetime of a contracting process.
|
||||||
|
type Milestone struct {
|
||||||
|
// A local identifier for this milestone, unique within this block.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Milestone title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The nature of the milestone, using the open
|
||||||
|
// [milestoneType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-type)
|
||||||
|
// codelist. Codelist: milestoneType.csv (open).
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
// A description of the milestone.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Milestone codes can be used to track specific events that take place for a particular kind
|
||||||
|
// of contracting process.
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
// The date the milestone is due.
|
||||||
|
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||||
|
// The date on which the milestone was met.
|
||||||
|
DateMet *time.Time `json:"dateMet,omitempty"`
|
||||||
|
// The date the milestone was last reviewed or modified and the status was altered or
|
||||||
|
// confirmed to still be correct.
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The status that was realized on the date provided in `dateModified`, from the closed
|
||||||
|
// [milestoneStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-status)
|
||||||
|
// codelist. Codelist: milestoneStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// List of documents associated with this milestone (Deprecated in 1.1).
|
||||||
|
// Deprecated: since OCDS 1.1. Inclusion of documents at the milestone level is now
|
||||||
|
// deprecated.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Organization: A party (organization)
|
||||||
|
type Organization struct {
|
||||||
|
// A common name for this organization or other participant in the contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The ID used for cross-referencing to this party from other sections of the release.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization or participant.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// A list of additional / supplemental identifiers for the organization or participant, using
|
||||||
|
// the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// An address.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// Contact details that can be used for this party.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
// The party's role(s) in the contracting process, using the open
|
||||||
|
// [partyRole](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#party-role)
|
||||||
|
// codelist. Codelist: partyRole.csv (open).
|
||||||
|
Roles []string `json:"roles,omitempty"`
|
||||||
|
// Additional classification information about parties can be provided using partyDetail
|
||||||
|
// extensions that define particular fields and classification schemes.
|
||||||
|
Details map[string]any `json:"details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationReference: The id and name of the party being referenced.
|
||||||
|
type OrganizationReference struct {
|
||||||
|
// The name of the party being referenced.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The id of the party being referenced.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization.
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and detailed legal identifier information should only be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and address information should only be provided in the
|
||||||
|
// relevant cross-referenced entry in the parties section at the top level of a release.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// (Deprecated outside the parties section) A list of additional / supplemental identifiers
|
||||||
|
// for the organization, using the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and additional identifiers for an organization should be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and contact point information for an organization should
|
||||||
|
// be provided in the relevant cross-referenced entry in the parties section at the top level
|
||||||
|
// of a release.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Period: Key events during a contracting process may have a known start date, end date,
|
||||||
|
// duration, or maximum extent (the latest date the period can extend to).
|
||||||
|
type Period struct {
|
||||||
|
// The start date for the period.
|
||||||
|
StartDate *time.Time `json:"startDate,omitempty"`
|
||||||
|
// The end date for the period.
|
||||||
|
EndDate *time.Time `json:"endDate,omitempty"`
|
||||||
|
// The period cannot be extended beyond this date.
|
||||||
|
MaxExtentDate *time.Time `json:"maxExtentDate,omitempty"`
|
||||||
|
// The maximum duration of this period in days.
|
||||||
|
DurationInDays *int `json:"durationInDays,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Planning: Information from the planning phase of the contracting process.
|
||||||
|
type Planning struct {
|
||||||
|
// The rationale for the procurement provided in free text.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// Details of the budget that funds this contracting process.
|
||||||
|
Budget *Budget `json:"budget,omitempty"`
|
||||||
|
// A list of documents related to the planning process.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the planning stage.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RelatedProcess: A reference to a related contracting process: generally one preceding or
|
||||||
|
// following on from the current process.
|
||||||
|
type RelatedProcess struct {
|
||||||
|
// A local identifier for this relationship, unique within this array.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The type of relationship, using the open
|
||||||
|
// [relatedProcess](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process)
|
||||||
|
// codelist. Codelist: relatedProcess.csv (open).
|
||||||
|
Relationship []string `json:"relationship,omitempty"`
|
||||||
|
// The title of the related process, where referencing an open contracting process, this field
|
||||||
|
// should match the tender/title field in the related process.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The identification scheme used by this cross-reference, using the open
|
||||||
|
// [relatedProcessScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process-scheme)
|
||||||
|
// codelist. Codelist: relatedProcessScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the related process.
|
||||||
|
Identifier string `json:"identifier,omitempty"`
|
||||||
|
// A URI pointing to a machine-readable document, release or record package containing the
|
||||||
|
// identified related process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tender: Data regarding tender process - publicly inviting prospective contractors to submit
|
||||||
|
// bids for evaluation and selecting a winner or winners.
|
||||||
|
type Tender struct {
|
||||||
|
// An identifier for this tender process.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A title for this tender.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A summary description of the tender.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the tender, from the closed
|
||||||
|
// [tenderStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#tender-status)
|
||||||
|
// codelist. Codelist: tenderStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The entity managing the procurement.
|
||||||
|
ProcuringEntity *OrganizationReference `json:"procuringEntity,omitempty"`
|
||||||
|
// The goods and services to be purchased, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The total upper estimated value of the procurement.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The minimum estimated value of the procurement.
|
||||||
|
MinValue *Value `json:"minValue,omitempty"`
|
||||||
|
// The procurement method, from the closed
|
||||||
|
// [method](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#method)
|
||||||
|
// codelist. Codelist: method.csv (closed).
|
||||||
|
ProcurementMethod string `json:"procurementMethod,omitempty"`
|
||||||
|
// Additional detail on the procurement method used.
|
||||||
|
ProcurementMethodDetails string `json:"procurementMethodDetails,omitempty"`
|
||||||
|
// Rationale for the chosen procurement method.
|
||||||
|
ProcurementMethodRationale string `json:"procurementMethodRationale,omitempty"`
|
||||||
|
// The primary category describing the main object of this contracting process, from the
|
||||||
|
// closed
|
||||||
|
// [procurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#procurement-category)
|
||||||
|
// codelist. Codelist: procurementCategory.csv (closed).
|
||||||
|
MainProcurementCategory string `json:"mainProcurementCategory,omitempty"`
|
||||||
|
// Any additional categories describing the objects of this contracting process, using the
|
||||||
|
// open
|
||||||
|
// [extendedProcurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#extended-procurement-category)
|
||||||
|
// codelist. Codelist: extendedProcurementCategory.csv (open).
|
||||||
|
AdditionalProcurementCategories []string `json:"additionalProcurementCategories,omitempty"`
|
||||||
|
// The award criteria for the procurement, using the open
|
||||||
|
// [awardCriteria](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-criteria)
|
||||||
|
// codelist. Codelist: awardCriteria.csv (open).
|
||||||
|
AwardCriteria string `json:"awardCriteria,omitempty"`
|
||||||
|
// Any detailed or further information on the award or selection criteria.
|
||||||
|
AwardCriteriaDetails string `json:"awardCriteriaDetails,omitempty"`
|
||||||
|
// The methods by which bids are submitted, using the open
|
||||||
|
// [submissionMethod](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#submission-method)
|
||||||
|
// codelist. Codelist: submissionMethod.csv (open).
|
||||||
|
SubmissionMethod []string `json:"submissionMethod,omitempty"`
|
||||||
|
// Any detailed or further information on the submission method.
|
||||||
|
SubmissionMethodDetails string `json:"submissionMethodDetails,omitempty"`
|
||||||
|
// The period when the tender is open for submissions.
|
||||||
|
TenderPeriod *Period `json:"tenderPeriod,omitempty"`
|
||||||
|
// The period during which potential bidders may submit questions and requests for
|
||||||
|
// clarification to the entity managing procurement.
|
||||||
|
EnquiryPeriod *Period `json:"enquiryPeriod,omitempty"`
|
||||||
|
// A true/false field to indicate whether any enquiries were received during the tender
|
||||||
|
// process.
|
||||||
|
HasEnquiries *bool `json:"hasEnquiries,omitempty"`
|
||||||
|
// A description of any eligibility criteria for potential suppliers.
|
||||||
|
EligibilityCriteria string `json:"eligibilityCriteria,omitempty"`
|
||||||
|
// The period for decision making regarding the contract award.
|
||||||
|
AwardPeriod *Period `json:"awardPeriod,omitempty"`
|
||||||
|
// The period over which the contract is estimated or required to be active.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// The number of parties who submit a bid.
|
||||||
|
NumberOfTenderers *int `json:"numberOfTenderers,omitempty"`
|
||||||
|
// All parties who submit a bid on a tender.
|
||||||
|
Tenderers []OrganizationReference `json:"tenderers,omitempty"`
|
||||||
|
// All documents and attachments related to the tender, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the tender.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A tender amendment is a formal change to the tender, and generally involves the publication
|
||||||
|
// of a new tender notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction: A spending transaction related to the contracting process.
|
||||||
|
type Transaction struct {
|
||||||
|
// A unique identifier for this transaction.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Used to point either to a corresponding Fiscal Data Package, IATI file, or machine or
|
||||||
|
// human-readable source where users can find further information on the budget line item
|
||||||
|
// identifiers, or project identifiers, provided here.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
// The date of the transaction
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The value of the transaction.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// An organization reference for the organization from which the funds in this transaction
|
||||||
|
// originate.
|
||||||
|
Payer *OrganizationReference `json:"payer,omitempty"`
|
||||||
|
// An organization reference for the organization which receives the funds in this
|
||||||
|
// transaction.
|
||||||
|
Payee *OrganizationReference `json:"payee,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about this spending transaction.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.value` field
|
||||||
|
// for consistency with the use of value and amount elsewhere in the standard.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payer` field
|
||||||
|
// to resolve ambiguity arising from 'provider' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ProviderOrganization *Identifier `json:"providerOrganization,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payee` field
|
||||||
|
// to resolve ambiguity arising from 'receiver' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ReceiverOrganization *Identifier `json:"receiverOrganization,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value: Financial values should be published with a currency attached.
|
||||||
|
type Value struct {
|
||||||
|
// Amount as a number.
|
||||||
|
Amount *float64 `json:"amount,omitempty"`
|
||||||
|
// The currency of the amount, from the closed
|
||||||
|
// [currency](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#currency)
|
||||||
|
// codelist. Codelist: currency.csv (closed).
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID is used for schema fields typed as ["string", "integer"], such as Item.id
|
||||||
|
// and Award.id. It accepts a JSON string or number and always encodes as a string.
|
||||||
|
type ID string
|
||||||
|
|
||||||
|
func (id *ID) UnmarshalJSON(b []byte) error {
|
||||||
|
if string(b) == "null" {
|
||||||
|
*id = ""
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(b, &s); err == nil {
|
||||||
|
*id = ID(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var n json.Number
|
||||||
|
if err := json.Unmarshal(b, &n); err != nil {
|
||||||
|
return fmt.Errorf("ID must be a string or integer, got %s", b)
|
||||||
|
}
|
||||||
|
*id = ID(n.String())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": [
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_suitability_extension/master/extension.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Package tenders holds OCDS types generated with the extensions in extensions.json.
|
||||||
|
package tenders
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p tenders
|
||||||
@@ -0,0 +1,764 @@
|
|||||||
|
// Code generated by ocdsgen from extensions.json. DO NOT EDIT.
|
||||||
|
|
||||||
|
// Package tenders contains Go types for OCDS releases with these extensions applied
|
||||||
|
// (dependencies first, in the order their patches were merged):
|
||||||
|
//
|
||||||
|
// - Lots (declared)
|
||||||
|
// https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json
|
||||||
|
// - Suitability (declared)
|
||||||
|
// https://raw.githubusercontent.com/open-contracting-extensions/ocds_suitability_extension/master/extension.json
|
||||||
|
package tenders
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeclaredExtensions are the extension URLs to list in ReleasePackage.Extensions.
|
||||||
|
var DeclaredExtensions = []string{
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_suitability_extension/master/extension.json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleasePackage: The release package contains a list of releases along with some publishing
|
||||||
|
// metadata.
|
||||||
|
type ReleasePackage struct {
|
||||||
|
// The URI of this package that identifies it uniquely in the world.
|
||||||
|
URI string `json:"uri"`
|
||||||
|
// The version of the OCDS schema used in this package, expressed as major.minor For example:
|
||||||
|
// 1.0 or 1.1
|
||||||
|
Version string `json:"version"`
|
||||||
|
// An array of OCDS extensions used in this package, in which each array item is the URL of an
|
||||||
|
// extension.json file.
|
||||||
|
Extensions []string `json:"extensions,omitempty"`
|
||||||
|
// The date that this package was published.
|
||||||
|
PublishedDate time.Time `json:"publishedDate"`
|
||||||
|
// An array of one or more OCDS releases.
|
||||||
|
Releases []Release `json:"releases"`
|
||||||
|
// Information to uniquely identify the publisher of this package.
|
||||||
|
Publisher *ReleasePackagePublisher `json:"publisher"`
|
||||||
|
// A link to the license that applies to the data in this package.
|
||||||
|
License string `json:"license,omitempty"`
|
||||||
|
// A link to a document describing the publishers [publication
|
||||||
|
// policy](https://standard.open-contracting.org/{{version}}/{{lang}}/guidance/publish/#finalize-your-publication-policy).
|
||||||
|
PublicationPolicy string `json:"publicationPolicy,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleasePackagePublisher: Information to uniquely identify the publisher of this package.
|
||||||
|
type ReleasePackagePublisher struct {
|
||||||
|
// The name of the organization or department responsible for publishing this data.
|
||||||
|
Name string `json:"name"`
|
||||||
|
// The scheme that holds the unique identifiers used to identify the item being identified.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The unique ID for this entity under the given ID scheme.
|
||||||
|
Uid string `json:"uid,omitempty"`
|
||||||
|
// A URI to identify the publisher.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release: Each release provides data about a single contracting process at a particular
|
||||||
|
// point in time.
|
||||||
|
type Release struct {
|
||||||
|
// A globally unique identifier for this Open Contracting Process.
|
||||||
|
OCID string `json:"ocid"`
|
||||||
|
// An identifier for this particular release of information.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// The date on which the information contained in the release was first recorded in, or
|
||||||
|
// published by, any system.
|
||||||
|
Date time.Time `json:"date"`
|
||||||
|
// One or more values from the closed
|
||||||
|
// [releaseTag](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#release-tag)
|
||||||
|
// codelist. Codelist: releaseTag.csv (closed).
|
||||||
|
Tag []string `json:"tag"`
|
||||||
|
// The type of initiation process used for this contract, from the closed
|
||||||
|
// [initiationType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#initiation-type)
|
||||||
|
// codelist. Codelist: initiationType.csv (closed).
|
||||||
|
InitiationType string `json:"initiationType"`
|
||||||
|
// Information on the parties (organizations, economic operators and other participants) who
|
||||||
|
// are involved in the contracting process and their roles, e.g.
|
||||||
|
Parties []Organization `json:"parties,omitempty"`
|
||||||
|
// A buyer is an entity whose budget will be used to pay for goods, works or services related
|
||||||
|
// to a contract.
|
||||||
|
Buyer *OrganizationReference `json:"buyer,omitempty"`
|
||||||
|
// Information from the planning phase of the contracting process.
|
||||||
|
Planning *Planning `json:"planning,omitempty"`
|
||||||
|
// The activities undertaken in order to enter into a contract.
|
||||||
|
Tender *Tender `json:"tender,omitempty"`
|
||||||
|
// Information from the award phase of the contracting process.
|
||||||
|
Awards []Award `json:"awards,omitempty"`
|
||||||
|
// Information from the contract creation phase of the procurement process.
|
||||||
|
Contracts []Contract `json:"contracts,omitempty"`
|
||||||
|
// The default language of the data using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process follows on from one or more
|
||||||
|
// other processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address: An address.
|
||||||
|
type Address struct {
|
||||||
|
// The street address.
|
||||||
|
StreetAddress string `json:"streetAddress,omitempty"`
|
||||||
|
// The locality.
|
||||||
|
Locality string `json:"locality,omitempty"`
|
||||||
|
// The region.
|
||||||
|
Region string `json:"region,omitempty"`
|
||||||
|
// The postal code.
|
||||||
|
PostalCode string `json:"postalCode,omitempty"`
|
||||||
|
// The country name.
|
||||||
|
CountryName string `json:"countryName,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amendment: Amendment information
|
||||||
|
type Amendment struct {
|
||||||
|
// The date of this amendment.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// An explanation for the amendment.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// An identifier for this amendment: often the amendment number
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// A free text, or semi-structured, description of the changes made in this amendment.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **before** the amendment was made.
|
||||||
|
AmendsReleaseID string `json:"amendsReleaseID,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **after** the amendment was made.
|
||||||
|
ReleaseID string `json:"releaseID,omitempty"`
|
||||||
|
// An array of change objects describing the fields changed, and their former values.
|
||||||
|
// Deprecated: since OCDS 1.1. A free-text or semi-structured string describing the changes
|
||||||
|
// made in each amendment can be provided in the amendment.description field.
|
||||||
|
Changes []AmendmentChanges `json:"changes,omitempty"`
|
||||||
|
// The identifiers of the lots to which this amendment relates.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AmendmentChanges struct {
|
||||||
|
// The property name that has been changed relative to the place the amendment is.
|
||||||
|
Property string `json:"property,omitempty"`
|
||||||
|
// The previous value of the changed property, in whatever type the property is.
|
||||||
|
FormerValue json.RawMessage `json:"former_value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Award: An award for the given procurement.
|
||||||
|
type Award struct {
|
||||||
|
// The identifier for this award.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Award title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Award description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the award, from the closed
|
||||||
|
// [awardStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-status)
|
||||||
|
// codelist. Codelist: awardStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The date of the contract award.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The total value of this award.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The suppliers awarded this award.
|
||||||
|
Suppliers []OrganizationReference `json:"suppliers,omitempty"`
|
||||||
|
// The goods and services awarded in this award, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The period for which the contract has been awarded.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// All documents and attachments related to the award, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// An award amendment is a formal change to the details of the award, and generally involves
|
||||||
|
// the publication of a new award notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
// The identifiers of the lots to which this award relates.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Budget: This section contains information about the budget line, and associated projects,
|
||||||
|
// through which this contracting process is funded.
|
||||||
|
type Budget struct {
|
||||||
|
// An identifier for the budget line item which provides funds for this contracting process.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A short free text description of the budget source.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The value reserved in the budget for this contracting process.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// The name of the project through which this contracting process is funded (if applicable).
|
||||||
|
Project string `json:"project,omitempty"`
|
||||||
|
// An external identifier for the project that this contracting process forms part of, or is
|
||||||
|
// funded via (if applicable).
|
||||||
|
ProjectID ID `json:"projectID,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about the budget line-item or
|
||||||
|
// line-items that fund this contracting process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1) Used to point either to a corresponding Budget Data Package, or to a
|
||||||
|
// machine or human-readable source where users can find further information on the budget
|
||||||
|
// line item identifiers, or project identifiers, provided here.
|
||||||
|
// Deprecated: since OCDS 1.1. The budget data source field was intended to link to
|
||||||
|
// machine-readable data about the budget for a contracting process, but has been widely
|
||||||
|
// mis-used to provide free-text descriptions of budget providers.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classification: A classification consists of at least two parts: an identifier for the list
|
||||||
|
// (scheme) from which the classification is taken, and an identifier for the category from
|
||||||
|
// that list being applied.
|
||||||
|
type Classification struct {
|
||||||
|
// The scheme or codelist from which the classification code is taken. Codelist:
|
||||||
|
// itemClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The classification code taken from the scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A textual description or title for the classification code.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A URI to uniquely identify the classification code.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContactPoint: A person, contact point or department to contact in relation to this
|
||||||
|
// contracting process.
|
||||||
|
type ContactPoint struct {
|
||||||
|
// The name of the contact person, department, or contact point, for correspondence relating
|
||||||
|
// to this contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The e-mail address of the contact point/person.
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
// The telephone number of the contact point/person.
|
||||||
|
Telephone string `json:"telephone,omitempty"`
|
||||||
|
// The fax number of the contact point/person.
|
||||||
|
FaxNumber string `json:"faxNumber,omitempty"`
|
||||||
|
// A web address for the contact point/person.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract: Information regarding the signed contract between the buyer and supplier(s).
|
||||||
|
type Contract struct {
|
||||||
|
// The identifier for this contract.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// The award.id against which this contract is being issued.
|
||||||
|
AwardID ID `json:"awardID"`
|
||||||
|
// Contract title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Contract description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the contract, from the closed
|
||||||
|
// [contractStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#contract-status)
|
||||||
|
// codelist. Codelist: contractStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The start and end date for the contract.
|
||||||
|
Period *Period `json:"period,omitempty"`
|
||||||
|
// The total value of this contract.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The goods, services, and any intangible outcomes in this contract.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The date the contract was signed.
|
||||||
|
DateSigned *time.Time `json:"dateSigned,omitempty"`
|
||||||
|
// All documents and attachments related to the contract, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// Information related to the implementation of the contract in accordance with the
|
||||||
|
// obligations laid out therein.
|
||||||
|
Implementation *Implementation `json:"implementation,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process is followed by one or more
|
||||||
|
// contracting processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
// A list of milestones associated with the finalization of this contract.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A contract amendment is a formal change to, or extension of, a contract, and generally
|
||||||
|
// involves the publication of a new contract notice/release, or some other documents
|
||||||
|
// detailing the change.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Document: Links to, or descriptions of, external documents can be attached at various
|
||||||
|
// locations within the standard.
|
||||||
|
type Document struct {
|
||||||
|
// A local, unique identifier for this document.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A classification of the document described, using the open
|
||||||
|
// [documentType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#document-type)
|
||||||
|
// codelist. Codelist: documentType.csv (open).
|
||||||
|
DocumentType string `json:"documentType,omitempty"`
|
||||||
|
// The document title.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A short description of the document.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A direct link to the document or attachment.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
// The date on which the document was first published.
|
||||||
|
DatePublished *time.Time `json:"datePublished,omitempty"`
|
||||||
|
// Date that the document was last modified
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The format of the document, using the open [IANA Media
|
||||||
|
// Types](https://www.iana.org/assignments/media-types/media-types.xhtml) codelist (see the
|
||||||
|
// values in the 'Template' column), or using the 'offline/print' code if the described
|
||||||
|
// document is published offline.
|
||||||
|
Format string `json:"format,omitempty"`
|
||||||
|
// The language of the linked document using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
// The identifiers of the lots to which this document relates.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identifier: A unique identifier for a party (organization).
|
||||||
|
type Identifier struct {
|
||||||
|
// Organization identifiers should be taken from an existing organization identifier list.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the organization in the selected scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The legally registered name of the organization.
|
||||||
|
LegalName string `json:"legalName,omitempty"`
|
||||||
|
// A URI to identify the organization, such as those provided by [Open
|
||||||
|
// Corporates](https://opencorporates.com) or some other relevant URI provider.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementation: Information during the performance / implementation stage of the contract.
|
||||||
|
type Implementation struct {
|
||||||
|
// A list of the spending transactions made against this contract
|
||||||
|
Transactions []Transaction `json:"transactions,omitempty"`
|
||||||
|
// As milestones are completed, the milestone's status and dates should be updated.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// Documents and reports that are part of the implementation phase e.g.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Item: A good, service, or work to be contracted.
|
||||||
|
type Item struct {
|
||||||
|
// A local identifier to reference and merge the items by.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A description of the goods, services to be provided.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The primary classification for the item.
|
||||||
|
Classification *Classification `json:"classification,omitempty"`
|
||||||
|
// An array of additional classifications for the item.
|
||||||
|
AdditionalClassifications []Classification `json:"additionalClassifications,omitempty"`
|
||||||
|
// The number of units to be provided.
|
||||||
|
Quantity *float64 `json:"quantity,omitempty"`
|
||||||
|
// A description of the unit in which the supplies, services or works are provided (e.g.
|
||||||
|
Unit *ItemUnit `json:"unit,omitempty"`
|
||||||
|
// The identifier of the lot to which this item relates.
|
||||||
|
RelatedLot string `json:"relatedLot,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemUnit: A description of the unit in which the supplies, services or works are provided
|
||||||
|
// (e.g.
|
||||||
|
type ItemUnit struct {
|
||||||
|
// The list from which identifiers for units of measure are taken, using the open
|
||||||
|
// [unitClassificationScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#unit-classification-scheme)
|
||||||
|
// codelist. Codelist: unitClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier from the codelist referenced in the `scheme` field.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// Name of the unit.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The monetary value of a single unit.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The machine-readable URI for the unit of measure, provided by the scheme.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lot: A lot is a grouping of items within a tender that can be bid on or awarded together.
|
||||||
|
type Lot struct {
|
||||||
|
// A local identifier for this lot, such as a lot number.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// Identifiers for this lot.
|
||||||
|
Identifiers []SimpleIdentifier `json:"identifiers,omitempty"`
|
||||||
|
// A title for this lot.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A description of this lot.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the process related to this lot. Codelist: tenderStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The maximum estimated value of this lot.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The estimated minimum value of the lot.
|
||||||
|
MinimumValue *Value `json:"minimumValue,omitempty"`
|
||||||
|
// The period when this lot is open for submissions.
|
||||||
|
TenderPeriod *Period `json:"tenderPeriod,omitempty"`
|
||||||
|
// The period over which the contract is estimated or specified to be active.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// The organization aiming to conclude a contract with a supplier or to use the goods, works
|
||||||
|
// or services in this lot.
|
||||||
|
Buyer *OrganizationReference `json:"buyer,omitempty"`
|
||||||
|
// Additional classifications for this lot.
|
||||||
|
AdditionalClassifications []Classification `json:"additionalClassifications,omitempty"`
|
||||||
|
// The primary category describing the main object of this lot, using the closed
|
||||||
|
// procurementCategory codelist. Codelist: procurementCategory.csv (closed).
|
||||||
|
MainProcurementCategory string `json:"mainProcurementCategory,omitempty"`
|
||||||
|
// Any additional categories describing the objects of this lot, using the open
|
||||||
|
// extendedProcurementCategory codelist. Codelist: extendedProcurementCategory.csv (open).
|
||||||
|
AdditionalProcurementCategories []string `json:"additionalProcurementCategories,omitempty"`
|
||||||
|
// The period during which potential bidders may submit questions and requests for
|
||||||
|
// clarification about this lot to the buyer or the procuring entity.
|
||||||
|
EnquiryPeriod *Period `json:"enquiryPeriod,omitempty"`
|
||||||
|
// Milestones associated with this lot.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// Information about the methods by which bids are submitted for this lot.
|
||||||
|
SubmissionMethodDetails string `json:"submissionMethodDetails,omitempty"`
|
||||||
|
// Information about how, when and where tenderers need to submit their bids.
|
||||||
|
SubmissionTerms json.RawMessage `json:"submissionTerms,omitempty"`
|
||||||
|
// Information about the suitability of the lot to different types of tenderers.
|
||||||
|
Suitability *Suitability `json:"suitability,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LotGroup: Where the buyer reserves the right to combine lots, or wishes to specify the
|
||||||
|
// total value for a group of lots, a lot group is used to capture this information.
|
||||||
|
type LotGroup struct {
|
||||||
|
// A local identifier for this group of lots.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// Identifiers for this lot group.
|
||||||
|
Identifiers []SimpleIdentifier `json:"identifiers,omitempty"`
|
||||||
|
// A title for this lot group.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A description of this lot group.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A list of the identifiers of the lots that form this group.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
// The buyer reserves the right to combine the lots in this group when awarding a contract.
|
||||||
|
OptionToCombine *bool `json:"optionToCombine,omitempty"`
|
||||||
|
// The maximum estimated value of the lots in this group.
|
||||||
|
MaximumValue *Value `json:"maximumValue,omitempty"`
|
||||||
|
// Information about the suitability of the lot group to different types of tenderers.
|
||||||
|
Suitability *Suitability `json:"suitability,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Milestone: The milestone block can be used to represent a wide variety of events in the
|
||||||
|
// lifetime of a contracting process.
|
||||||
|
type Milestone struct {
|
||||||
|
// A local identifier for this milestone, unique within this block.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Milestone title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The nature of the milestone, using the open
|
||||||
|
// [milestoneType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-type)
|
||||||
|
// codelist. Codelist: milestoneType.csv (open).
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
// A description of the milestone.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Milestone codes can be used to track specific events that take place for a particular kind
|
||||||
|
// of contracting process.
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
// The date the milestone is due.
|
||||||
|
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||||
|
// The date on which the milestone was met.
|
||||||
|
DateMet *time.Time `json:"dateMet,omitempty"`
|
||||||
|
// The date the milestone was last reviewed or modified and the status was altered or
|
||||||
|
// confirmed to still be correct.
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The status that was realized on the date provided in `dateModified`, from the closed
|
||||||
|
// [milestoneStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-status)
|
||||||
|
// codelist. Codelist: milestoneStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// List of documents associated with this milestone (Deprecated in 1.1).
|
||||||
|
// Deprecated: since OCDS 1.1. Inclusion of documents at the milestone level is now
|
||||||
|
// deprecated.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// The identifiers of the lots to which this milestone relates.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Organization: A party (organization)
|
||||||
|
type Organization struct {
|
||||||
|
// A common name for this organization or other participant in the contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The ID used for cross-referencing to this party from other sections of the release.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization or participant.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// A list of additional / supplemental identifiers for the organization or participant, using
|
||||||
|
// the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// An address.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// Contact details that can be used for this party.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
// The party's role(s) in the contracting process, using the open
|
||||||
|
// [partyRole](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#party-role)
|
||||||
|
// codelist. Codelist: partyRole.csv (open).
|
||||||
|
Roles []string `json:"roles,omitempty"`
|
||||||
|
// Additional classification information about parties can be provided using partyDetail
|
||||||
|
// extensions that define particular fields and classification schemes.
|
||||||
|
Details map[string]any `json:"details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationReference: The id and name of the party being referenced.
|
||||||
|
type OrganizationReference struct {
|
||||||
|
// The name of the party being referenced.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The id of the party being referenced.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization.
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and detailed legal identifier information should only be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and address information should only be provided in the
|
||||||
|
// relevant cross-referenced entry in the parties section at the top level of a release.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// (Deprecated outside the parties section) A list of additional / supplemental identifiers
|
||||||
|
// for the organization, using the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and additional identifiers for an organization should be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and contact point information for an organization should
|
||||||
|
// be provided in the relevant cross-referenced entry in the parties section at the top level
|
||||||
|
// of a release.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Period: Key events during a contracting process may have a known start date, end date,
|
||||||
|
// duration, or maximum extent (the latest date the period can extend to).
|
||||||
|
type Period struct {
|
||||||
|
// The start date for the period.
|
||||||
|
StartDate *time.Time `json:"startDate,omitempty"`
|
||||||
|
// The end date for the period.
|
||||||
|
EndDate *time.Time `json:"endDate,omitempty"`
|
||||||
|
// The period cannot be extended beyond this date.
|
||||||
|
MaxExtentDate *time.Time `json:"maxExtentDate,omitempty"`
|
||||||
|
// The maximum duration of this period in days.
|
||||||
|
DurationInDays *int `json:"durationInDays,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Planning: Information from the planning phase of the contracting process.
|
||||||
|
type Planning struct {
|
||||||
|
// The rationale for the procurement provided in free text.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// Details of the budget that funds this contracting process.
|
||||||
|
Budget *Budget `json:"budget,omitempty"`
|
||||||
|
// A list of documents related to the planning process.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the planning stage.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RelatedProcess: A reference to a related contracting process: generally one preceding or
|
||||||
|
// following on from the current process.
|
||||||
|
type RelatedProcess struct {
|
||||||
|
// A local identifier for this relationship, unique within this array.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The type of relationship, using the open
|
||||||
|
// [relatedProcess](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process)
|
||||||
|
// codelist. Codelist: relatedProcess.csv (open).
|
||||||
|
Relationship []string `json:"relationship,omitempty"`
|
||||||
|
// The title of the related process, where referencing an open contracting process, this field
|
||||||
|
// should match the tender/title field in the related process.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The identification scheme used by this cross-reference, using the open
|
||||||
|
// [relatedProcessScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process-scheme)
|
||||||
|
// codelist. Codelist: relatedProcessScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the related process.
|
||||||
|
Identifier string `json:"identifier,omitempty"`
|
||||||
|
// A URI pointing to a machine-readable document, release or record package containing the
|
||||||
|
// identified related process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// The identifiers of the lots in the related process to which this process relates.
|
||||||
|
RelatedLots []string `json:"relatedLots,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SimpleIdentifier: An unambiguous reference to a resource within a given context.
|
||||||
|
type SimpleIdentifier struct {
|
||||||
|
// The list, register or system from which the identifier is taken.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier taken from the scheme.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Suitability: Information about the suitability of a contracting process, lot or lot group
|
||||||
|
// to different types of tenderers.
|
||||||
|
type Suitability struct {
|
||||||
|
// Whether the contracting process, lot or lot group is suitable to small and medium
|
||||||
|
// enterprises.
|
||||||
|
SME *bool `json:"sme,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tender: Data regarding tender process - publicly inviting prospective contractors to submit
|
||||||
|
// bids for evaluation and selecting a winner or winners.
|
||||||
|
type Tender struct {
|
||||||
|
// An identifier for this tender process.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A title for this tender.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A summary description of the tender.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the tender, from the closed
|
||||||
|
// [tenderStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#tender-status)
|
||||||
|
// codelist. Codelist: tenderStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The entity managing the procurement.
|
||||||
|
ProcuringEntity *OrganizationReference `json:"procuringEntity,omitempty"`
|
||||||
|
// The goods and services to be purchased, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The total upper estimated value of the procurement.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The minimum estimated value of the procurement.
|
||||||
|
MinValue *Value `json:"minValue,omitempty"`
|
||||||
|
// The procurement method, from the closed
|
||||||
|
// [method](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#method)
|
||||||
|
// codelist. Codelist: method.csv (closed).
|
||||||
|
ProcurementMethod string `json:"procurementMethod,omitempty"`
|
||||||
|
// Additional detail on the procurement method used.
|
||||||
|
ProcurementMethodDetails string `json:"procurementMethodDetails,omitempty"`
|
||||||
|
// Rationale for the chosen procurement method.
|
||||||
|
ProcurementMethodRationale string `json:"procurementMethodRationale,omitempty"`
|
||||||
|
// The primary category describing the main object of this contracting process, from the
|
||||||
|
// closed
|
||||||
|
// [procurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#procurement-category)
|
||||||
|
// codelist. Codelist: procurementCategory.csv (closed).
|
||||||
|
MainProcurementCategory string `json:"mainProcurementCategory,omitempty"`
|
||||||
|
// Any additional categories describing the objects of this contracting process, using the
|
||||||
|
// open
|
||||||
|
// [extendedProcurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#extended-procurement-category)
|
||||||
|
// codelist. Codelist: extendedProcurementCategory.csv (open).
|
||||||
|
AdditionalProcurementCategories []string `json:"additionalProcurementCategories,omitempty"`
|
||||||
|
// The award criteria for the procurement, using the open
|
||||||
|
// [awardCriteria](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-criteria)
|
||||||
|
// codelist. Codelist: awardCriteria.csv (open).
|
||||||
|
AwardCriteria string `json:"awardCriteria,omitempty"`
|
||||||
|
// Any detailed or further information on the award or selection criteria.
|
||||||
|
AwardCriteriaDetails string `json:"awardCriteriaDetails,omitempty"`
|
||||||
|
// The methods by which bids are submitted, using the open
|
||||||
|
// [submissionMethod](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#submission-method)
|
||||||
|
// codelist. Codelist: submissionMethod.csv (open).
|
||||||
|
SubmissionMethod []string `json:"submissionMethod,omitempty"`
|
||||||
|
// Any detailed or further information on the submission method.
|
||||||
|
SubmissionMethodDetails string `json:"submissionMethodDetails,omitempty"`
|
||||||
|
// The period when the tender is open for submissions.
|
||||||
|
TenderPeriod *Period `json:"tenderPeriod,omitempty"`
|
||||||
|
// The period during which potential bidders may submit questions and requests for
|
||||||
|
// clarification to the entity managing procurement.
|
||||||
|
EnquiryPeriod *Period `json:"enquiryPeriod,omitempty"`
|
||||||
|
// A true/false field to indicate whether any enquiries were received during the tender
|
||||||
|
// process.
|
||||||
|
HasEnquiries *bool `json:"hasEnquiries,omitempty"`
|
||||||
|
// A description of any eligibility criteria for potential suppliers.
|
||||||
|
EligibilityCriteria string `json:"eligibilityCriteria,omitempty"`
|
||||||
|
// The period for decision making regarding the contract award.
|
||||||
|
AwardPeriod *Period `json:"awardPeriod,omitempty"`
|
||||||
|
// The period over which the contract is estimated or required to be active.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// The number of parties who submit a bid.
|
||||||
|
NumberOfTenderers *int `json:"numberOfTenderers,omitempty"`
|
||||||
|
// All parties who submit a bid on a tender.
|
||||||
|
Tenderers []OrganizationReference `json:"tenderers,omitempty"`
|
||||||
|
// All documents and attachments related to the tender, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the tender.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A tender amendment is a formal change to the tender, and generally involves the publication
|
||||||
|
// of a new tender notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
// A tender process can be divided into lots, where bidders can bid on one or more lots.
|
||||||
|
Lots []Lot `json:"lots,omitempty"`
|
||||||
|
// Details of any criteria that apply to bidding on the lots in this tender.
|
||||||
|
LotDetails *TenderLotDetails `json:"lotDetails,omitempty"`
|
||||||
|
// Where the buyer reserves the right to combine lots, or wishes to specify the total value
|
||||||
|
// for a group of lots, a lot group is used to capture this information.
|
||||||
|
LotGroups []LotGroup `json:"lotGroups,omitempty"`
|
||||||
|
// Information about the suitability of the contracting process to different types of
|
||||||
|
// tenderers.
|
||||||
|
Suitability *Suitability `json:"suitability,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TenderLotDetails: Details of any criteria that apply to bidding on the lots in this tender.
|
||||||
|
type TenderLotDetails struct {
|
||||||
|
// The maximum number of lots that one supplier can bid on as part of this contracting
|
||||||
|
// process.
|
||||||
|
MaximumLotsBidPerSupplier *int `json:"maximumLotsBidPerSupplier,omitempty"`
|
||||||
|
// The maximum number of lots that can be awarded to one supplier as part of this contracting
|
||||||
|
// process.
|
||||||
|
MaximumLotsAwardedPerSupplier *int `json:"maximumLotsAwardedPerSupplier,omitempty"`
|
||||||
|
// Any detailed or further information on the award or selection criteria.
|
||||||
|
AwardCriteriaDetails string `json:"awardCriteriaDetails,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction: A spending transaction related to the contracting process.
|
||||||
|
type Transaction struct {
|
||||||
|
// A unique identifier for this transaction.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Used to point either to a corresponding Fiscal Data Package, IATI file, or machine or
|
||||||
|
// human-readable source where users can find further information on the budget line item
|
||||||
|
// identifiers, or project identifiers, provided here.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
// The date of the transaction
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The value of the transaction.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// An organization reference for the organization from which the funds in this transaction
|
||||||
|
// originate.
|
||||||
|
Payer *OrganizationReference `json:"payer,omitempty"`
|
||||||
|
// An organization reference for the organization which receives the funds in this
|
||||||
|
// transaction.
|
||||||
|
Payee *OrganizationReference `json:"payee,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about this spending transaction.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.value` field
|
||||||
|
// for consistency with the use of value and amount elsewhere in the standard.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payer` field
|
||||||
|
// to resolve ambiguity arising from 'provider' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ProviderOrganization *Identifier `json:"providerOrganization,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payee` field
|
||||||
|
// to resolve ambiguity arising from 'receiver' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ReceiverOrganization *Identifier `json:"receiverOrganization,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value: Financial values should be published with a currency attached.
|
||||||
|
type Value struct {
|
||||||
|
// Amount as a number.
|
||||||
|
Amount *float64 `json:"amount,omitempty"`
|
||||||
|
// The currency of the amount, from the closed
|
||||||
|
// [currency](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#currency)
|
||||||
|
// codelist. Codelist: currency.csv (closed).
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID is used for schema fields typed as ["string", "integer"], such as Item.id
|
||||||
|
// and Award.id. It accepts a JSON string or number and always encodes as a string.
|
||||||
|
type ID string
|
||||||
|
|
||||||
|
func (id *ID) UnmarshalJSON(b []byte) error {
|
||||||
|
if string(b) == "null" {
|
||||||
|
*id = ""
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(b, &s); err == nil {
|
||||||
|
*id = ID(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var n json.Number
|
||||||
|
if err := json.Unmarshal(b, &n); err != nil {
|
||||||
|
return fmt.Errorf("ID must be a string or integer, got %s", b)
|
||||||
|
}
|
||||||
|
*id = ID(n.String())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Command myapp shows three packages, each with its own extension set, used side by side.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"example.com/myapp/internal/budgets"
|
||||||
|
"example.com/myapp/internal/tenders"
|
||||||
|
"git.avsdev.uk/Go/go-ocds/profiles/uk"
|
||||||
|
)
|
||||||
|
|
||||||
|
const data = `{"ocid":"ocds-1","id":"r1","date":"2026-09-01T00:00:00Z","tag":["tender"],"initiationType":"tender",
|
||||||
|
"planning":{"budget":{"id":"B1","budgetBreakdown":[{"id":"BB1","amount":{"amount":500,"currency":"GBP"}}]}},
|
||||||
|
"tender":{"id":"T1","lots":[{"id":"L1","suitability":{"sme":true}}]}}`
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// The same JSON decodes into each package; each one sees only the fields
|
||||||
|
// its extensions define (other fields are ignored on decode).
|
||||||
|
var t tenders.Release
|
||||||
|
var b budgets.Release
|
||||||
|
var u uk.Release
|
||||||
|
for _, v := range []any{&t, &b, &u} {
|
||||||
|
if err := json.Unmarshal([]byte(data), v); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println("tenders: lot L1 SME-suitable =", *t.Tender.Lots[0].Suitability.SME)
|
||||||
|
fmt.Println("budgets: breakdown amount =", *b.Planning.Budget.BudgetBreakdown[0].Amount.Amount)
|
||||||
|
fmt.Println("uk: lots =", len(u.Tender.Lots))
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build tools
|
||||||
|
|
||||||
|
// This file records the generator as a module dependency so `go mod tidy`
|
||||||
|
// keeps it and `go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen` uses the version
|
||||||
|
// pinned in go.mod. On Go 1.24+, use `go get -tool` instead (see README).
|
||||||
|
package tools
|
||||||
|
|
||||||
|
import _ "git.avsdev.uk/Go/go-ocds/cmd/ocdsgen"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
module git.avsdev.uk/Go/go-ocds
|
||||||
|
|
||||||
|
go 1.21
|
||||||
|
|
||||||
|
require github.com/spf13/cobra v1.10.2
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.9 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||||
|
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||||
|
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
|
||||||
|
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// run executes the command tree with args and returns stdout, stderr and the error.
|
||||||
|
func run(t *testing.T, args ...string) (string, string, error) {
|
||||||
|
t.Helper()
|
||||||
|
var stdout, stderr bytes.Buffer
|
||||||
|
cmd := NewRootCmd()
|
||||||
|
cmd.SetOut(&stdout)
|
||||||
|
cmd.SetErr(&stderr)
|
||||||
|
cmd.SetArgs(args)
|
||||||
|
err := cmd.Execute()
|
||||||
|
return stdout.String(), stderr.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGenerate(t *testing.T) {
|
||||||
|
out := filepath.Join(t.TempDir(), "tenders", "ocds_gen.go")
|
||||||
|
if err := os.MkdirAll(filepath.Dir(out), 0o755); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, stderr, err := run(t, "generate", "-c", "testdata/widgets.json", "-o", out); err != nil {
|
||||||
|
t.Fatalf("generate: %v\n%s", err, stderr)
|
||||||
|
}
|
||||||
|
raw, err := os.ReadFile(out)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// gofmt aligns struct columns, so compare with whitespace collapsed.
|
||||||
|
src := strings.Join(strings.Fields(string(raw)), " ")
|
||||||
|
for _, want := range []string{
|
||||||
|
"package tenders", // derived from the output directory
|
||||||
|
"Date time.Time", // required date-time is not a pointer
|
||||||
|
"ID ID `json:\"id\"`", // ["string","integer"]
|
||||||
|
"Widgets []Widget", // extension field on a core type
|
||||||
|
"Count *int", // extension definition
|
||||||
|
"Releases []Release", // external $ref to the release schema
|
||||||
|
"Widgets (declared)", // header records resolution
|
||||||
|
"Orphan (dependency)",
|
||||||
|
} {
|
||||||
|
if !strings.Contains(src, want) {
|
||||||
|
t.Errorf("generated code is missing %q", want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGenerateStdoutNeedsPackage(t *testing.T) {
|
||||||
|
_, _, err := run(t, "generate", "-c", "testdata/core.json", "-o", "-")
|
||||||
|
if err == nil || !strings.Contains(err.Error(), "--package") {
|
||||||
|
t.Fatalf("want --package error, got %v", err)
|
||||||
|
}
|
||||||
|
stdout, _, err := run(t, "generate", "-c", "testdata/core.json", "-o", "-", "-p", "core")
|
||||||
|
if err != nil || !strings.HasPrefix(stdout, "// Code generated") {
|
||||||
|
t.Fatalf("stdout generation failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCheck(t *testing.T) {
|
||||||
|
out := filepath.Join(t.TempDir(), "ocds_gen.go")
|
||||||
|
args := []string{"generate", "-q", "-c", "testdata/core.json", "-o", out, "-p", "core"}
|
||||||
|
|
||||||
|
if _, _, err := run(t, append(args, "--check")...); err == nil || !strings.Contains(err.Error(), "does not exist") {
|
||||||
|
t.Fatalf("missing file: want error, got %v", err)
|
||||||
|
}
|
||||||
|
if _, _, err := run(t, args...); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, _, err := run(t, append(args, "--check")...); err != nil {
|
||||||
|
t.Fatalf("fresh file: want no error, got %v", err)
|
||||||
|
}
|
||||||
|
f, _ := os.OpenFile(out, os.O_APPEND|os.O_WRONLY, 0)
|
||||||
|
f.WriteString("// hand edit\n")
|
||||||
|
f.Close()
|
||||||
|
if _, _, err := run(t, append(args, "--check")...); err == nil || !strings.Contains(err.Error(), "out of date") {
|
||||||
|
t.Fatalf("edited file: want out-of-date error, got %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStrict(t *testing.T) {
|
||||||
|
out := filepath.Join(t.TempDir(), "ocds_gen.go")
|
||||||
|
args := []string{"generate", "-c", "testdata/widgets.json", "-o", out, "-p", "x"}
|
||||||
|
|
||||||
|
// Gadget is defined by the Orphan extension but nothing refers to it.
|
||||||
|
_, stderr, err := run(t, args...)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(stderr, "definition Gadget is never referenced") {
|
||||||
|
t.Errorf("want unreachable warning, got stderr:\n%s", stderr)
|
||||||
|
}
|
||||||
|
if _, _, err := run(t, append(args, "--strict")...); err == nil {
|
||||||
|
t.Fatal("--strict: want error")
|
||||||
|
}
|
||||||
|
if _, stderr, _ := run(t, append(args, "-q")...); stderr != "" {
|
||||||
|
t.Errorf("--quiet: want no stderr, got:\n%s", stderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestResolveJSON(t *testing.T) {
|
||||||
|
stdout, _, err := run(t, "resolve", "-c", "testdata/widgets.json", "--json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var rows []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Declared bool `json:"declared"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal([]byte(stdout), &rows); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(rows) != 2 || rows[0].Name != "Orphan" || rows[0].Declared || rows[1].Name != "Widgets" || !rows[1].Declared {
|
||||||
|
t.Fatalf("want [Orphan (dependency), Widgets (declared)], got %+v", rows)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSchema(t *testing.T) {
|
||||||
|
stdout, _, err := run(t, "schema", "-q", "-c", "testdata/widgets.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// Key order is preserved, and the extension's patch is merged in.
|
||||||
|
if !strings.Contains(stdout, `"widgets"`) || strings.Index(stdout, `"ocid"`) > strings.Index(stdout, `"tender"`) {
|
||||||
|
t.Fatalf("unexpected merged schema:\n%s", stdout)
|
||||||
|
}
|
||||||
|
if _, _, err := run(t, "schema", "--kind", "record", "-c", "testdata/core.json"); err == nil {
|
||||||
|
t.Fatal("--kind record: want error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPackageFromPath(t *testing.T) {
|
||||||
|
for in, want := range map[string]string{
|
||||||
|
"internal/tenders/ocds_gen.go": "tenders",
|
||||||
|
"profiles/uk/ocds_gen.go": "uk",
|
||||||
|
"pkg/eu-profile/x.go": "euprofile",
|
||||||
|
} {
|
||||||
|
got, err := packageFromPath(in)
|
||||||
|
if err != nil || got != want {
|
||||||
|
t.Errorf("packageFromPath(%q) = %q, %v; want %q", in, got, err, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := packageFromPath("pkg/func/x.go"); err == nil {
|
||||||
|
t.Error("keyword directory: want error")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"go/token"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGenerateCmd(opts *options) *cobra.Command {
|
||||||
|
var (
|
||||||
|
out string
|
||||||
|
pkg string
|
||||||
|
check bool
|
||||||
|
excludeFieldDoc bool
|
||||||
|
)
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "generate",
|
||||||
|
Short: "Generate Go types from the config",
|
||||||
|
Long: `Generate fetches the schemas and extensions named in the config and writes
|
||||||
|
the Go types to --out. Use --out - to write to stdout.
|
||||||
|
|
||||||
|
With --check, nothing is written; the command fails if the output file is
|
||||||
|
missing or differs from what would be generated. Use this in CI to catch
|
||||||
|
generated code that is stale or was edited by hand.`,
|
||||||
|
Example: ` ocdsgen generate -c extensions.json -o ocds_gen.go -p tenders
|
||||||
|
ocdsgen generate --check --strict
|
||||||
|
//go:generate go tool ocdsgen generate -c extensions.json -o ocds_gen.go -p tenders`,
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
|
if pkg == "" {
|
||||||
|
var err error
|
||||||
|
if pkg, err = packageFromPath(out); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg, g, err := opts.setup(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
src, err := g.Run(cfg, pkg, filepath.Base(opts.config), excludeFieldDoc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case out == "-":
|
||||||
|
if _, err := cmd.OutOrStdout().Write(src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case check:
|
||||||
|
existing, err := os.ReadFile(out)
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
return fmt.Errorf("%s does not exist; run ocdsgen generate", out)
|
||||||
|
} else if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !bytes.Equal(existing, src) {
|
||||||
|
return fmt.Errorf("%s is out of date; run ocdsgen generate", out)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(cmd.ErrOrStderr(), "%s is up to date\n", out)
|
||||||
|
default:
|
||||||
|
if err := os.WriteFile(out, src, 0o644); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return opts.finish(g)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
f := cmd.Flags()
|
||||||
|
f.StringVarP(&out, "out", "o", "ocds_gen.go", `output Go file, or "-" for stdout`)
|
||||||
|
f.StringVarP(&pkg, "package", "p", "", "Go package name (default: name of the output file's directory)")
|
||||||
|
f.BoolVar(&check, "check", false, "verify the output file is up to date instead of writing it")
|
||||||
|
f.BoolVar(&excludeFieldDoc, "exclude-field-doc", false, `exclude documentation for definition fields`)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// packageFromPath derives a package name from the directory the output file
|
||||||
|
// will be written to, e.g. internal/tenders/ocds_gen.go -> tenders.
|
||||||
|
func packageFromPath(out string) (string, error) {
|
||||||
|
if out == "-" {
|
||||||
|
return "", errors.New("--package is required when writing to stdout")
|
||||||
|
}
|
||||||
|
abs, err := filepath.Abs(out)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
dir := filepath.Base(filepath.Dir(abs))
|
||||||
|
name := strings.Map(func(r rune) rune {
|
||||||
|
if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' {
|
||||||
|
return unicode.ToLower(r)
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}, dir)
|
||||||
|
if !token.IsIdentifier(name) || token.IsKeyword(name) {
|
||||||
|
return "", fmt.Errorf("can't derive a package name from directory %q; pass --package", dir)
|
||||||
|
}
|
||||||
|
return name, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"text/tabwriter"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newResolveCmd(opts *options) *cobra.Command {
|
||||||
|
var asJSON bool
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "resolve",
|
||||||
|
Short: "List the extensions the config resolves to, in merge order",
|
||||||
|
Long: `Resolve fetches each extension in the config and its dependencies, and prints
|
||||||
|
them in the order their patches are applied. Dependencies come first. Nothing
|
||||||
|
is generated.`,
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
|
cfg, g, err := opts.setup(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
exts, err := g.Resolve(cfg.Extensions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if asJSON {
|
||||||
|
type row struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Declared bool `json:"declared"`
|
||||||
|
Dependencies []string `json:"dependencies,omitempty"`
|
||||||
|
}
|
||||||
|
rows := make([]row, len(exts))
|
||||||
|
for i, e := range exts {
|
||||||
|
rows[i] = row{e.Name, e.URL, e.Declared, e.Dependencies}
|
||||||
|
}
|
||||||
|
enc := json.NewEncoder(cmd.OutOrStdout())
|
||||||
|
enc.SetIndent("", " ")
|
||||||
|
if err := enc.Encode(rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0)
|
||||||
|
fmt.Fprintln(w, "#\tNAME\tSOURCE\tURL")
|
||||||
|
for i, e := range exts {
|
||||||
|
src := "dependency"
|
||||||
|
if e.Declared {
|
||||||
|
src = "declared"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(w, "%d\t%s\t%s\t%s\n", i+1, e.Name, src, e.URL)
|
||||||
|
}
|
||||||
|
if err := w.Flush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return opts.finish(g)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
cmd.Flags().BoolVar(&asJSON, "json", false, "print as JSON")
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// Package cli defines the ocdsgen command tree using Cobra. The commands are
|
||||||
|
// thin wrappers around internal/generator.
|
||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"git.avsdev.uk/Go/go-ocds/internal/generator"
|
||||||
|
)
|
||||||
|
|
||||||
|
// options are the flags shared by every subcommand.
|
||||||
|
type options struct {
|
||||||
|
config string
|
||||||
|
timeout time.Duration
|
||||||
|
strict bool
|
||||||
|
quiet bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRootCmd builds the command tree. It returns a fresh tree on each call so
|
||||||
|
// tests can run commands in isolation.
|
||||||
|
func NewRootCmd() *cobra.Command {
|
||||||
|
opts := &options{}
|
||||||
|
|
||||||
|
root := &cobra.Command{
|
||||||
|
Use: "ocdsgen",
|
||||||
|
Short: "Generate Go types for OCDS releases with chosen extensions",
|
||||||
|
Long: `ocdsgen reads an extensions.json config listing the OCDS core schemas and
|
||||||
|
extension URLs, resolves extension dependencies, applies each extension's
|
||||||
|
schema patch in order, and generates Go structs from the result.`,
|
||||||
|
SilenceUsage: true, // don't print usage on runtime errors
|
||||||
|
SilenceErrors: true, // main prints the error once
|
||||||
|
}
|
||||||
|
|
||||||
|
pf := root.PersistentFlags()
|
||||||
|
pf.StringVarP(&opts.config, "config", "c", "extensions.json", "path to the extensions config file")
|
||||||
|
pf.DurationVar(&opts.timeout, "timeout", 60*time.Second, "timeout for each HTTP request")
|
||||||
|
pf.BoolVar(&opts.strict, "strict", false, "fail if the generator reports any warnings")
|
||||||
|
pf.BoolVarP(&opts.quiet, "quiet", "q", false, "don't print notes and warnings")
|
||||||
|
|
||||||
|
root.AddCommand(
|
||||||
|
newGenerateCmd(opts),
|
||||||
|
newResolveCmd(opts),
|
||||||
|
newSchemaCmd(opts),
|
||||||
|
)
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup loads the config and creates a Generator that logs to the command's
|
||||||
|
// stderr (or nowhere, with --quiet).
|
||||||
|
func (o *options) setup(cmd *cobra.Command) (*generator.Config, *generator.Generator, error) {
|
||||||
|
cfg, err := generator.LoadConfig(o.config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
var log io.Writer = cmd.ErrOrStderr()
|
||||||
|
if o.quiet {
|
||||||
|
log = io.Discard
|
||||||
|
}
|
||||||
|
return cfg, generator.New(log, o.timeout), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// finish enforces --strict once a command's work is done.
|
||||||
|
func (o *options) finish(g *generator.Generator) error {
|
||||||
|
if n := g.Warnings(); o.strict && n > 0 {
|
||||||
|
return fmt.Errorf("%d warning(s) reported and --strict is set", n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSchemaCmd(opts *options) *cobra.Command {
|
||||||
|
var (
|
||||||
|
kind string
|
||||||
|
out string
|
||||||
|
)
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "schema",
|
||||||
|
Short: "Write the merged JSON Schema (core plus extensions)",
|
||||||
|
Long: `Schema writes the release or release package schema with every extension
|
||||||
|
in the config applied. This is the schema the Go types are generated from,
|
||||||
|
which is useful for debugging a config or validating data with other tools.`,
|
||||||
|
Example: ` ocdsgen schema > release-schema.json
|
||||||
|
ocdsgen schema --kind package -o release-package-schema.json`,
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
|
if kind != "release" && kind != "package" {
|
||||||
|
return fmt.Errorf(`--kind must be "release" or "package", got %q`, kind)
|
||||||
|
}
|
||||||
|
cfg, g, err := opts.setup(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
exts, err := g.Resolve(cfg.Extensions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s, err := g.Merge(cfg, exts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
doc := s.Release
|
||||||
|
if kind == "package" {
|
||||||
|
doc = s.Package
|
||||||
|
}
|
||||||
|
b, err := json.MarshalIndent(doc, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b = append(b, '\n')
|
||||||
|
|
||||||
|
if out == "-" {
|
||||||
|
_, err = cmd.OutOrStdout().Write(b)
|
||||||
|
} else {
|
||||||
|
err = os.WriteFile(out, b, 0o644)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return opts.finish(g)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
f := cmd.Flags()
|
||||||
|
f.StringVar(&kind, "kind", "release", `which schema to write: "release" or "package"`)
|
||||||
|
f.StringVarP(&out, "out", "o", "-", `output file, or "-" for stdout`)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "release-schema.json",
|
||||||
|
"releasePackageSchema": "release-package-schema.json",
|
||||||
|
"extensions": []
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"name": {"en": "Orphan"}, "schemas": ["release-schema.json"]}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"definitions": {"Gadget": {"type": "object", "properties": {"name": {"type": "string"}}}}}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"uri": {"type": "string", "format": "uri"},
|
||||||
|
"releases": {"type": "array", "items": {"$ref": "https://standard.open-contracting.org/schema/1__1__5/release-schema.json"}}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": ["ocid", "id", "date"],
|
||||||
|
"properties": {
|
||||||
|
"ocid": {"type": "string", "description": "Open Contracting ID."},
|
||||||
|
"id": {"type": "string"},
|
||||||
|
"date": {"type": "string", "format": "date-time"},
|
||||||
|
"tender": {"$ref": "#/definitions/Tender"}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"Tender": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["id"],
|
||||||
|
"properties": {
|
||||||
|
"id": {"type": ["string", "integer"]},
|
||||||
|
"title": {"type": ["string", "null"]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "release-schema.json",
|
||||||
|
"releasePackageSchema": "release-package-schema.json",
|
||||||
|
"extensions": ["widgets/extension.json"]
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"name": {"en": "Widgets"}, "schemas": ["release-schema.json"], "dependencies": ["../orphan/extension.json"]}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"definitions": {
|
||||||
|
"Tender": {"properties": {"widgets": {"type": "array", "items": {"$ref": "#/definitions/Widget"}}}},
|
||||||
|
"Widget": {"type": "object", "properties": {"id": {"type": "string"}, "count": {"type": "integer"}}}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
package generator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"go/format"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
)
|
||||||
|
|
||||||
|
type field struct {
|
||||||
|
GoName, JSONName, Type, Doc string
|
||||||
|
Required bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type goStruct struct {
|
||||||
|
Name, Doc string
|
||||||
|
Fields []field
|
||||||
|
}
|
||||||
|
|
||||||
|
type emitter struct {
|
||||||
|
defs *Obj // release schema definitions
|
||||||
|
defNames map[string]string // schema definition name -> Go type name
|
||||||
|
used map[string]bool // Go type names taken
|
||||||
|
structs []*goStruct
|
||||||
|
usesTime bool
|
||||||
|
usesJSON bool
|
||||||
|
usesID bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit renders Go source for the merged schemas. declared is the list of
|
||||||
|
// extension URLs from the config, recorded as DeclaredExtensions.
|
||||||
|
func (gen *Generator) Emit(pkg, configName string, s *Schemas, exts []*Extension, declared []string, excludeFieldDoc bool) ([]byte, error) {
|
||||||
|
release, pkgSchema := s.Release, s.Package
|
||||||
|
g := &emitter{
|
||||||
|
defs: release.Obj("definitions"),
|
||||||
|
defNames: map[string]string{},
|
||||||
|
used: map[string]bool{"ID": true},
|
||||||
|
}
|
||||||
|
if g.defs == nil {
|
||||||
|
g.defs = newObj()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reserve names up front so inline types never take a definition's name.
|
||||||
|
g.used["Release"], g.used["ReleasePackage"] = true, true
|
||||||
|
names := append([]string(nil), g.defs.Keys...)
|
||||||
|
sort.Strings(names)
|
||||||
|
for _, n := range names {
|
||||||
|
gn := g.unique(goName(n))
|
||||||
|
g.defNames[n] = gn
|
||||||
|
}
|
||||||
|
|
||||||
|
gen.warnUnreachable(release, pkgSchema)
|
||||||
|
|
||||||
|
g.addStruct("ReleasePackage", pkgSchema)
|
||||||
|
g.addStruct("Release", release)
|
||||||
|
for _, n := range names {
|
||||||
|
g.addStruct(g.defNames[n], g.defs.Obj(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
fmt.Fprintf(&b, "// Code generated by ocdsgen from %s. DO NOT EDIT.\n\n", configName)
|
||||||
|
fmt.Fprintf(&b, "// Package %s contains Go types for OCDS releases with these extensions applied\n", pkg)
|
||||||
|
fmt.Fprintf(&b, "// (dependencies first, in the order their patches were merged):\n//\n")
|
||||||
|
for _, e := range exts {
|
||||||
|
tag := "dependency"
|
||||||
|
if e.Declared {
|
||||||
|
tag = "declared"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, "// - %s (%s)\n// %s\n", e.Name, tag, e.URL)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, "package %s\n\n", pkg)
|
||||||
|
|
||||||
|
var imports []string
|
||||||
|
if g.usesID {
|
||||||
|
imports = append(imports, `"fmt"`)
|
||||||
|
}
|
||||||
|
if g.usesJSON || g.usesID {
|
||||||
|
imports = append(imports, `"encoding/json"`)
|
||||||
|
}
|
||||||
|
if g.usesTime {
|
||||||
|
imports = append(imports, `"time"`)
|
||||||
|
}
|
||||||
|
if len(imports) > 0 {
|
||||||
|
fmt.Fprintf(&b, "import (\n%s\n)\n\n", strings.Join(imports, "\n"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(&b, "// DeclaredExtensions are the extension URLs to list in ReleasePackage.Extensions.\n")
|
||||||
|
fmt.Fprintf(&b, "var DeclaredExtensions = []string{\n")
|
||||||
|
for _, u := range declared {
|
||||||
|
fmt.Fprintf(&b, "\t%s,\n", strconv.Quote(u))
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, "}\n\n")
|
||||||
|
|
||||||
|
for _, s := range g.structs {
|
||||||
|
writeDoc(&b, "", s.Doc)
|
||||||
|
fmt.Fprintf(&b, "type %s struct {\n", s.Name)
|
||||||
|
for _, f := range s.Fields {
|
||||||
|
if !excludeFieldDoc {
|
||||||
|
writeDoc(&b, "\t", f.Doc)
|
||||||
|
}
|
||||||
|
tag := f.JSONName
|
||||||
|
if !f.Required {
|
||||||
|
tag += ",omitempty"
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, "\t%s %s `json:%s`\n", f.GoName, f.Type, strconv.Quote(tag))
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&b, "}\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
if g.usesID {
|
||||||
|
b.WriteString(idType)
|
||||||
|
}
|
||||||
|
|
||||||
|
src, err := format.Source(b.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return b.Bytes(), fmt.Errorf("gofmt generated code: %w", err)
|
||||||
|
}
|
||||||
|
return src, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *emitter) unique(name string) string {
|
||||||
|
n := name
|
||||||
|
for i := 2; g.used[n]; i++ {
|
||||||
|
n = fmt.Sprintf("%s%d", name, i)
|
||||||
|
}
|
||||||
|
g.used[n] = true
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
// addStruct emits a struct for an object schema. Inline object properties
|
||||||
|
// become their own named types, emitted directly after their parent.
|
||||||
|
func (g *emitter) addStruct(name string, schema *Obj) {
|
||||||
|
s := &goStruct{Name: name, Doc: docFor(name, schema)}
|
||||||
|
g.structs = append(g.structs, s)
|
||||||
|
|
||||||
|
required := map[string]bool{}
|
||||||
|
if req, ok := schema.Get("required").([]any); ok {
|
||||||
|
for _, r := range req {
|
||||||
|
if rs, ok := r.(string); ok {
|
||||||
|
required[rs] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
props := schema.Obj("properties")
|
||||||
|
if props == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
taken := map[string]bool{}
|
||||||
|
for _, key := range props.Keys {
|
||||||
|
ps, ok := props.M[key].(*Obj)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
gn := goName(key)
|
||||||
|
for i := 2; taken[gn]; i++ {
|
||||||
|
gn = fmt.Sprintf("%s%d", goName(key), i)
|
||||||
|
}
|
||||||
|
taken[gn] = true
|
||||||
|
|
||||||
|
typ := g.typeOf(name+goName(key), ps)
|
||||||
|
req := required[key]
|
||||||
|
if req && typ == "*time.Time" {
|
||||||
|
typ = "time.Time"
|
||||||
|
}
|
||||||
|
s.Fields = append(s.Fields, field{GoName: gn, JSONName: key, Type: typ, Doc: docFor("", ps), Required: req})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// typeOf maps a property schema to a Go type. inlineName is used if the
|
||||||
|
// property is an object with its own properties.
|
||||||
|
func (g *emitter) typeOf(inlineName string, s *Obj) string {
|
||||||
|
if ref := s.Str("$ref"); ref != "" {
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(ref, "#/definitions/"):
|
||||||
|
if gn, ok := g.defNames[strings.TrimPrefix(ref, "#/definitions/")]; ok {
|
||||||
|
return "*" + gn
|
||||||
|
}
|
||||||
|
case strings.HasSuffix(ref, "release-schema.json"):
|
||||||
|
return "*Release"
|
||||||
|
}
|
||||||
|
g.usesJSON = true
|
||||||
|
return "json.RawMessage" // unresolvable reference
|
||||||
|
}
|
||||||
|
|
||||||
|
types := typeSet(s)
|
||||||
|
if len(types) == 0 {
|
||||||
|
if s.Obj("properties") != nil {
|
||||||
|
types = []string{"object"}
|
||||||
|
} else {
|
||||||
|
g.usesJSON = true
|
||||||
|
return "json.RawMessage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(types) > 1 {
|
||||||
|
sort.Strings(types)
|
||||||
|
if strings.Join(types, ",") == "integer,string" {
|
||||||
|
g.usesID = true
|
||||||
|
return "ID"
|
||||||
|
}
|
||||||
|
g.usesJSON = true
|
||||||
|
return "json.RawMessage"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch types[0] {
|
||||||
|
case "string":
|
||||||
|
if s.Str("format") == "date-time" {
|
||||||
|
g.usesTime = true
|
||||||
|
return "*time.Time"
|
||||||
|
}
|
||||||
|
return "string"
|
||||||
|
case "integer":
|
||||||
|
return "*int"
|
||||||
|
case "number":
|
||||||
|
return "*float64"
|
||||||
|
case "boolean":
|
||||||
|
return "*bool"
|
||||||
|
case "array":
|
||||||
|
items, ok := s.Get("items").(*Obj)
|
||||||
|
if !ok {
|
||||||
|
g.usesJSON = true
|
||||||
|
return "[]json.RawMessage"
|
||||||
|
}
|
||||||
|
return "[]" + strings.TrimPrefix(g.typeOf(inlineName, items), "*")
|
||||||
|
case "object":
|
||||||
|
if s.Obj("properties") != nil {
|
||||||
|
n := g.unique(inlineName)
|
||||||
|
g.addStruct(n, s)
|
||||||
|
return "*" + n
|
||||||
|
}
|
||||||
|
return "map[string]any"
|
||||||
|
}
|
||||||
|
g.usesJSON = true
|
||||||
|
return "json.RawMessage"
|
||||||
|
}
|
||||||
|
|
||||||
|
// warnUnreachable reports definitions that no field refers to. This usually
|
||||||
|
// means an extension patches a definition (e.g. Lot) that is introduced by
|
||||||
|
// another extension (e.g. Lots) which isn't in the config, so the patched
|
||||||
|
// fields would have nowhere to appear in the data.
|
||||||
|
func (gen *Generator) warnUnreachable(release, pkgSchema *Obj) {
|
||||||
|
defs := release.Obj("definitions")
|
||||||
|
if defs == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reached := map[string]bool{}
|
||||||
|
var walk func(v any)
|
||||||
|
walk = func(v any) {
|
||||||
|
switch t := v.(type) {
|
||||||
|
case *Obj:
|
||||||
|
if ref := t.Str("$ref"); strings.HasPrefix(ref, "#/definitions/") {
|
||||||
|
name := strings.TrimPrefix(ref, "#/definitions/")
|
||||||
|
if !reached[name] {
|
||||||
|
reached[name] = true
|
||||||
|
if d := defs.Obj(name); d != nil {
|
||||||
|
walk(d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, k := range t.Keys {
|
||||||
|
if k != "definitions" {
|
||||||
|
walk(t.M[k])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case []any:
|
||||||
|
for _, x := range t {
|
||||||
|
walk(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
walk(release)
|
||||||
|
walk(pkgSchema)
|
||||||
|
for _, name := range defs.Keys {
|
||||||
|
if !reached[name] {
|
||||||
|
gen.warnf("definition %s is never referenced; an extension that embeds it may be missing from the config", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func typeSet(s *Obj) []string {
|
||||||
|
var out []string
|
||||||
|
switch t := s.Get("type").(type) {
|
||||||
|
case string:
|
||||||
|
if t != "null" {
|
||||||
|
out = append(out, t)
|
||||||
|
}
|
||||||
|
case []any:
|
||||||
|
for _, v := range t {
|
||||||
|
if vs, ok := v.(string); ok && vs != "null" {
|
||||||
|
out = append(out, vs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func docFor(name string, s *Obj) string {
|
||||||
|
var parts []string
|
||||||
|
desc := firstSentence(s.Str("description"))
|
||||||
|
if desc == "" {
|
||||||
|
desc = s.Str("title")
|
||||||
|
}
|
||||||
|
if desc != "" {
|
||||||
|
if name != "" {
|
||||||
|
desc = name + ": " + desc
|
||||||
|
}
|
||||||
|
parts = append(parts, desc)
|
||||||
|
}
|
||||||
|
if cl := s.Str("codelist"); cl != "" {
|
||||||
|
kind := "closed"
|
||||||
|
if open, _ := s.Get("openCodelist").(bool); open {
|
||||||
|
kind = "open"
|
||||||
|
}
|
||||||
|
parts = append(parts, fmt.Sprintf("Codelist: %s (%s).", cl, kind))
|
||||||
|
}
|
||||||
|
if dep, ok := s.Get("deprecated").(*Obj); ok {
|
||||||
|
msg := firstSentence(dep.Str("description"))
|
||||||
|
if v := dep.Str("deprecatedVersion"); v != "" {
|
||||||
|
msg = fmt.Sprintf("since OCDS %s. %s", v, msg)
|
||||||
|
}
|
||||||
|
parts = append(parts, "\nDeprecated: "+strings.TrimSpace(msg))
|
||||||
|
}
|
||||||
|
return strings.Join(parts, " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func firstSentence(s string) string {
|
||||||
|
s = strings.Join(strings.Fields(s), " ")
|
||||||
|
if i := strings.Index(s, ". "); i >= 0 {
|
||||||
|
s = s[:i+1]
|
||||||
|
}
|
||||||
|
if len(s) > 300 {
|
||||||
|
s = s[:297] + "..."
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeDoc(b *bytes.Buffer, indent, doc string) {
|
||||||
|
if doc == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, para := range strings.Split(doc, "\n") {
|
||||||
|
line := ""
|
||||||
|
for _, w := range strings.Fields(para) {
|
||||||
|
if line != "" && len(line)+len(w) > 90 {
|
||||||
|
fmt.Fprintf(b, "%s// %s\n", indent, line)
|
||||||
|
line = ""
|
||||||
|
}
|
||||||
|
if line != "" {
|
||||||
|
line += " "
|
||||||
|
}
|
||||||
|
line += w
|
||||||
|
}
|
||||||
|
if line != "" {
|
||||||
|
fmt.Fprintf(b, "%s// %s\n", indent, line)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(b, "%s//\n", indent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var initialisms = map[string]bool{
|
||||||
|
"ID": true, "URI": true, "URL": true, "OCID": true, "JSON": true, "HTML": true,
|
||||||
|
"HTTP": true, "VAT": true, "EU": true, "UK": true, "SME": true, "CPV": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// goName converts a JSON key or definition name to an exported Go identifier,
|
||||||
|
// e.g. "awardID" -> "AwardID", "relatedLots" -> "RelatedLots", "uri" -> "URI".
|
||||||
|
func goName(s string) string {
|
||||||
|
var words []string
|
||||||
|
var cur []rune
|
||||||
|
flush := func() {
|
||||||
|
if len(cur) > 0 {
|
||||||
|
words = append(words, string(cur))
|
||||||
|
cur = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs := []rune(s)
|
||||||
|
for i, r := range rs {
|
||||||
|
if !unicode.IsLetter(r) && !unicode.IsDigit(r) {
|
||||||
|
flush()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if unicode.IsUpper(r) && len(cur) > 0 {
|
||||||
|
prev := cur[len(cur)-1]
|
||||||
|
nextLower := i+1 < len(rs) && unicode.IsLower(rs[i+1])
|
||||||
|
if unicode.IsLower(prev) || unicode.IsDigit(prev) || (unicode.IsUpper(prev) && nextLower) {
|
||||||
|
flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur = append(cur, r)
|
||||||
|
}
|
||||||
|
flush()
|
||||||
|
|
||||||
|
var out strings.Builder
|
||||||
|
for _, w := range words {
|
||||||
|
if up := strings.ToUpper(w); initialisms[up] {
|
||||||
|
out.WriteString(up)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
r := []rune(w)
|
||||||
|
out.WriteString(string(unicode.ToUpper(r[0])))
|
||||||
|
out.WriteString(string(r[1:]))
|
||||||
|
}
|
||||||
|
name := out.String()
|
||||||
|
if name == "" {
|
||||||
|
return "Field"
|
||||||
|
}
|
||||||
|
if unicode.IsDigit([]rune(name)[0]) {
|
||||||
|
name = "X" + name
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
// idType is emitted into every generated package that needs it, so each
|
||||||
|
// package is self-contained and has no runtime dependency on this module.
|
||||||
|
const idType = `
|
||||||
|
// ID is used for schema fields typed as ["string", "integer"], such as Item.id
|
||||||
|
// and Award.id. It accepts a JSON string or number and always encodes as a string.
|
||||||
|
type ID string
|
||||||
|
|
||||||
|
func (id *ID) UnmarshalJSON(b []byte) error {
|
||||||
|
if string(b) == "null" {
|
||||||
|
*id = ""
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(b, &s); err == nil {
|
||||||
|
*id = ID(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var n json.Number
|
||||||
|
if err := json.Unmarshal(b, &n); err != nil {
|
||||||
|
return fmt.Errorf("ID must be a string or integer, got %s", b)
|
||||||
|
}
|
||||||
|
*id = ID(n.String())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
`
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
// Package generator builds Go types for OCDS releases from the core schema
|
||||||
|
// plus a set of extensions. It is used by the ocdsgen command and has no
|
||||||
|
// knowledge of the command line.
|
||||||
|
package generator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config is the contents of an extensions.json file.
|
||||||
|
type Config struct {
|
||||||
|
ReleaseSchema string `json:"releaseSchema"`
|
||||||
|
ReleasePackageSchema string `json:"releasePackageSchema"`
|
||||||
|
Extensions []string `json:"extensions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadConfig reads and validates a config file. Entries that are relative
|
||||||
|
// local paths rather than URLs are resolved against the config file's directory.
|
||||||
|
func LoadConfig(p string) (*Config, error) {
|
||||||
|
raw, err := os.ReadFile(p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var cfg Config
|
||||||
|
if err := json.Unmarshal(raw, &cfg); err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", p, err)
|
||||||
|
}
|
||||||
|
if cfg.ReleaseSchema == "" || cfg.ReleasePackageSchema == "" {
|
||||||
|
return nil, fmt.Errorf("%s: releaseSchema and releasePackageSchema are required", p)
|
||||||
|
}
|
||||||
|
dir := filepath.Dir(p)
|
||||||
|
cfg.ReleaseSchema = relativeTo(dir, cfg.ReleaseSchema)
|
||||||
|
cfg.ReleasePackageSchema = relativeTo(dir, cfg.ReleasePackageSchema)
|
||||||
|
for i, e := range cfg.Extensions {
|
||||||
|
cfg.Extensions[i] = relativeTo(dir, e)
|
||||||
|
}
|
||||||
|
return &cfg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func relativeTo(dir, ref string) string {
|
||||||
|
if strings.Contains(ref, "://") || filepath.IsAbs(ref) {
|
||||||
|
return ref
|
||||||
|
}
|
||||||
|
return filepath.Join(dir, ref)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension is one resolved extension.
|
||||||
|
type Extension struct {
|
||||||
|
URL string
|
||||||
|
Name string
|
||||||
|
Schemas []string
|
||||||
|
Dependencies []string
|
||||||
|
Declared bool // listed in the config rather than pulled in as a dependency
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schemas holds the core schemas after extension patches are applied.
|
||||||
|
type Schemas struct {
|
||||||
|
Release *Obj
|
||||||
|
Package *Obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generator holds shared state for a run: an HTTP client, a fetch cache and
|
||||||
|
// where warnings go. The zero value is not usable; call New.
|
||||||
|
type Generator struct {
|
||||||
|
client *http.Client
|
||||||
|
cache map[string][]byte
|
||||||
|
log io.Writer
|
||||||
|
warnings int
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns a Generator that writes notes and warnings to log.
|
||||||
|
func New(log io.Writer, timeout time.Duration) *Generator {
|
||||||
|
if log == nil {
|
||||||
|
log = io.Discard
|
||||||
|
}
|
||||||
|
return &Generator{client: &http.Client{Timeout: timeout}, cache: map[string][]byte{}, log: log}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warnings reports how many warnings have been emitted so far.
|
||||||
|
func (g *Generator) Warnings() int { return g.warnings }
|
||||||
|
|
||||||
|
func (g *Generator) warnf(format string, args ...any) {
|
||||||
|
g.warnings++
|
||||||
|
fmt.Fprintf(g.log, "warning: "+format+"\n", args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Generator) notef(format string, args ...any) {
|
||||||
|
fmt.Fprintf(g.log, "note: "+format+"\n", args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run resolves, merges and emits in one step.
|
||||||
|
func (g *Generator) Run(cfg *Config, pkg, configName string, excludeFieldDoc bool) ([]byte, error) {
|
||||||
|
exts, err := g.Resolve(cfg.Extensions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s, err := g.Merge(cfg, exts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return g.Emit(pkg, configName, s, exts, cfg.Extensions, excludeFieldDoc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve fetches each extension's metadata and walks dependencies
|
||||||
|
// depth-first, so every extension comes after the extensions it depends on.
|
||||||
|
// Each URL appears once.
|
||||||
|
func (g *Generator) Resolve(urls []string) ([]*Extension, error) {
|
||||||
|
var order []*Extension
|
||||||
|
seen := map[string]bool{}
|
||||||
|
visiting := map[string]bool{}
|
||||||
|
declared := map[string]bool{}
|
||||||
|
for _, u := range urls {
|
||||||
|
declared[u] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
var visit func(u string) error
|
||||||
|
visit = func(u string) error {
|
||||||
|
if seen[u] {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if visiting[u] {
|
||||||
|
return fmt.Errorf("dependency cycle at %s", u)
|
||||||
|
}
|
||||||
|
visiting[u] = true
|
||||||
|
|
||||||
|
var meta struct {
|
||||||
|
Name map[string]string `json:"name"`
|
||||||
|
Schemas []string `json:"schemas"`
|
||||||
|
Dependencies []string `json:"dependencies"`
|
||||||
|
}
|
||||||
|
body, err := g.fetch(u)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(body, &meta); err != nil {
|
||||||
|
return fmt.Errorf("%s: %w", u, err)
|
||||||
|
}
|
||||||
|
e := &Extension{
|
||||||
|
URL: u,
|
||||||
|
Name: meta.Name["en"],
|
||||||
|
Schemas: meta.Schemas,
|
||||||
|
Dependencies: meta.Dependencies,
|
||||||
|
Declared: declared[u],
|
||||||
|
}
|
||||||
|
if e.Name == "" {
|
||||||
|
e.Name = u
|
||||||
|
}
|
||||||
|
for i, d := range meta.Dependencies {
|
||||||
|
// Dependencies are usually absolute URLs; relative ones are
|
||||||
|
// resolved against the extension that declares them.
|
||||||
|
if d, err = resolveRef(u, d); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
e.Dependencies[i] = d
|
||||||
|
if err := visit(d); err != nil {
|
||||||
|
return fmt.Errorf("%s -> %w", e.Name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visiting[u] = false
|
||||||
|
seen[u] = true
|
||||||
|
order = append(order, e)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, u := range urls {
|
||||||
|
if err := visit(u); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g.warnDuplicateRepos(order)
|
||||||
|
return order, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge fetches the core schemas and applies each extension's patches in
|
||||||
|
// order using JSON Merge Patch, as the OCDS tooling does.
|
||||||
|
func (g *Generator) Merge(cfg *Config, exts []*Extension) (*Schemas, error) {
|
||||||
|
release, err := g.fetchObj(cfg.ReleaseSchema)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pkg, err := g.fetchObj(cfg.ReleasePackageSchema)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, e := range exts {
|
||||||
|
for _, s := range e.Schemas {
|
||||||
|
var target **Obj
|
||||||
|
switch path.Base(s) {
|
||||||
|
case "release-schema.json":
|
||||||
|
target = &release
|
||||||
|
case "release-package-schema.json":
|
||||||
|
target = &pkg
|
||||||
|
default:
|
||||||
|
g.notef("%s: skipping %s (not generated)", e.Name, s)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
schemaURL, err := resolveRef(e.URL, s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
patch, err := g.fetchObj(schemaURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", e.Name, err)
|
||||||
|
}
|
||||||
|
g.warnTypeConflicts(e.Name, *target, patch)
|
||||||
|
*target = mergePatch(*target, patch).(*Obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &Schemas{Release: release, Package: pkg}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// warnDuplicateRepos flags the same extension pulled in at two different
|
||||||
|
// versions (e.g. .../master/extension.json and .../v1.1.5/extension.json).
|
||||||
|
func (g *Generator) warnDuplicateRepos(exts []*Extension) {
|
||||||
|
byRepo := map[string][]string{}
|
||||||
|
for _, e := range exts {
|
||||||
|
u, err := url.Parse(e.URL)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
parts := strings.Split(strings.Trim(u.Path, "/"), "/")
|
||||||
|
if len(parts) >= 2 {
|
||||||
|
repo := strings.ToLower(parts[0] + "/" + parts[1])
|
||||||
|
byRepo[repo] = append(byRepo[repo], e.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repos := make([]string, 0, len(byRepo))
|
||||||
|
for r := range byRepo {
|
||||||
|
repos = append(repos, r)
|
||||||
|
}
|
||||||
|
sort.Strings(repos)
|
||||||
|
for _, r := range repos {
|
||||||
|
if len(byRepo[r]) > 1 {
|
||||||
|
g.warnf("%s is included more than once: %s", r, strings.Join(byRepo[r], ", "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// warnTypeConflicts reports when a patch changes the JSON type of an existing
|
||||||
|
// property, which usually means two extensions disagree.
|
||||||
|
func (g *Generator) warnTypeConflicts(ext string, target, patch *Obj) {
|
||||||
|
check := func(where string, tProps, pProps *Obj) {
|
||||||
|
if tProps == nil || pProps == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, k := range pProps.Keys {
|
||||||
|
pp, _ := pProps.M[k].(*Obj)
|
||||||
|
tp, _ := tProps.M[k].(*Obj)
|
||||||
|
if pp == nil || tp == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if a, b := typeKey(tp), typeKey(pp); a != "" && b != "" && a != b {
|
||||||
|
g.warnf("%s changes %s.%s from %s to %s", ext, where, k, a, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check("Release", target.Obj("properties"), patch.Obj("properties"))
|
||||||
|
pDefs, tDefs := patch.Obj("definitions"), target.Obj("definitions")
|
||||||
|
if pDefs == nil || tDefs == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, name := range pDefs.Keys {
|
||||||
|
if pd, td := pDefs.Obj(name), tDefs.Obj(name); pd != nil && td != nil {
|
||||||
|
check(name, td.Obj("properties"), pd.Obj("properties"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func typeKey(s *Obj) string {
|
||||||
|
if ref := s.Str("$ref"); ref != "" {
|
||||||
|
return "$ref:" + ref
|
||||||
|
}
|
||||||
|
ts := typeSet(s)
|
||||||
|
sort.Strings(ts)
|
||||||
|
return strings.Join(ts, "|")
|
||||||
|
}
|
||||||
|
|
||||||
|
func resolveRef(base, ref string) (string, error) {
|
||||||
|
if !strings.Contains(base, "://") {
|
||||||
|
// Local path: URL resolution would turn "a/b.json" + "../c.json"
|
||||||
|
// into "/c.json", so use file path rules instead.
|
||||||
|
if strings.Contains(ref, "://") || filepath.IsAbs(ref) {
|
||||||
|
return ref, nil
|
||||||
|
}
|
||||||
|
return filepath.Join(filepath.Dir(base), ref), nil
|
||||||
|
}
|
||||||
|
b, err := url.Parse(base)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
r, err := url.Parse(ref)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return b.ResolveReference(r).String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Generator) fetch(u string) ([]byte, error) {
|
||||||
|
if b, ok := g.cache[u]; ok {
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
var body []byte
|
||||||
|
if strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://") {
|
||||||
|
resp, err := g.client.Get(u)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("GET %s: %s", u, resp.Status)
|
||||||
|
}
|
||||||
|
if body, err = io.ReadAll(resp.Body); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Local paths are allowed, e.g. for a vendored or private extension.
|
||||||
|
var err error
|
||||||
|
if body, err = os.ReadFile(strings.TrimPrefix(u, "file://")); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g.cache[u] = body
|
||||||
|
return body, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Generator) fetchObj(u string) (*Obj, error) {
|
||||||
|
body, err := g.fetch(u)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
v, err := decodeOrdered(bytes.NewReader(body))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", u, err)
|
||||||
|
}
|
||||||
|
o, ok := v.(*Obj)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("%s: not a JSON object", u)
|
||||||
|
}
|
||||||
|
return o, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package generator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Obj is a JSON object that remembers key order, so generated structs list
|
||||||
|
// fields in the same order as the schema rather than alphabetically.
|
||||||
|
type Obj struct {
|
||||||
|
Keys []string
|
||||||
|
M map[string]any
|
||||||
|
}
|
||||||
|
|
||||||
|
func newObj() *Obj { return &Obj{M: map[string]any{}} }
|
||||||
|
|
||||||
|
func (o *Obj) Get(k string) any { return o.M[k] }
|
||||||
|
|
||||||
|
func (o *Obj) Set(k string, v any) {
|
||||||
|
if _, ok := o.M[k]; !ok {
|
||||||
|
o.Keys = append(o.Keys, k)
|
||||||
|
}
|
||||||
|
o.M[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Obj) Delete(k string) {
|
||||||
|
if _, ok := o.M[k]; !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete(o.M, k)
|
||||||
|
for i, key := range o.Keys {
|
||||||
|
if key == k {
|
||||||
|
o.Keys = append(o.Keys[:i], o.Keys[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Obj) Obj(k string) *Obj {
|
||||||
|
v, _ := o.M[k].(*Obj)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Obj) Str(k string) string {
|
||||||
|
v, _ := o.M[k].(string)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// decodeOrdered parses JSON, returning *Obj for objects, []any for arrays,
|
||||||
|
// and string / json.Number / bool / nil for scalars.
|
||||||
|
func decodeOrdered(r io.Reader) (any, error) {
|
||||||
|
dec := json.NewDecoder(r)
|
||||||
|
dec.UseNumber()
|
||||||
|
return parseValue(dec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseValue(dec *json.Decoder) (any, error) {
|
||||||
|
tok, err := dec.Token()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch t := tok.(type) {
|
||||||
|
case json.Delim:
|
||||||
|
switch t {
|
||||||
|
case '{':
|
||||||
|
o := newObj()
|
||||||
|
for dec.More() {
|
||||||
|
kt, err := dec.Token()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
k, ok := kt.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("expected object key, got %v", kt)
|
||||||
|
}
|
||||||
|
v, err := parseValue(dec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
o.Set(k, v)
|
||||||
|
}
|
||||||
|
_, err := dec.Token() // '}'
|
||||||
|
return o, err
|
||||||
|
case '[':
|
||||||
|
arr := []any{}
|
||||||
|
for dec.More() {
|
||||||
|
v, err := parseValue(dec)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
arr = append(arr, v)
|
||||||
|
}
|
||||||
|
_, err := dec.Token() // ']'
|
||||||
|
return arr, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected delimiter %v", t)
|
||||||
|
default:
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mergePatch applies an RFC 7386 JSON Merge Patch, which is how OCDS
|
||||||
|
// extensions are applied to the core schema. A null in the patch deletes
|
||||||
|
// the key; objects merge recursively; anything else replaces.
|
||||||
|
func mergePatch(target, patch any) any {
|
||||||
|
p, ok := patch.(*Obj)
|
||||||
|
if !ok {
|
||||||
|
return patch
|
||||||
|
}
|
||||||
|
t, ok := target.(*Obj)
|
||||||
|
if !ok {
|
||||||
|
t = newObj()
|
||||||
|
}
|
||||||
|
for _, k := range p.Keys {
|
||||||
|
v := p.M[k]
|
||||||
|
if v == nil {
|
||||||
|
t.Delete(k)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.Set(k, mergePatch(t.M[k], v))
|
||||||
|
}
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON writes the object with its keys in their original order.
|
||||||
|
func (o *Obj) MarshalJSON() ([]byte, error) {
|
||||||
|
var b bytes.Buffer
|
||||||
|
b.WriteByte('{')
|
||||||
|
for i, k := range o.Keys {
|
||||||
|
if i > 0 {
|
||||||
|
b.WriteByte(',')
|
||||||
|
}
|
||||||
|
kb, err := json.Marshal(k)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
vb, err := json.Marshal(o.M[k])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
b.Write(kb)
|
||||||
|
b.WriteByte(':')
|
||||||
|
b.Write(vb)
|
||||||
|
}
|
||||||
|
b.WriteByte('}')
|
||||||
|
return b.Bytes(), nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Package core contains OCDS 1.1 types with no extensions applied.
|
||||||
|
package core
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p core
|
||||||
@@ -0,0 +1,641 @@
|
|||||||
|
// Code generated by ocdsgen from extensions.json. DO NOT EDIT.
|
||||||
|
|
||||||
|
// Package core contains Go types for OCDS releases with these extensions applied
|
||||||
|
// (dependencies first, in the order their patches were merged):
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeclaredExtensions are the extension URLs to list in ReleasePackage.Extensions.
|
||||||
|
var DeclaredExtensions = []string{}
|
||||||
|
|
||||||
|
// ReleasePackage: The release package contains a list of releases along with some publishing
|
||||||
|
// metadata.
|
||||||
|
type ReleasePackage struct {
|
||||||
|
// The URI of this package that identifies it uniquely in the world.
|
||||||
|
URI string `json:"uri"`
|
||||||
|
// The version of the OCDS schema used in this package, expressed as major.minor For example:
|
||||||
|
// 1.0 or 1.1
|
||||||
|
Version string `json:"version"`
|
||||||
|
// An array of OCDS extensions used in this package, in which each array item is the URL of an
|
||||||
|
// extension.json file.
|
||||||
|
Extensions []string `json:"extensions,omitempty"`
|
||||||
|
// The date that this package was published.
|
||||||
|
PublishedDate time.Time `json:"publishedDate"`
|
||||||
|
// An array of one or more OCDS releases.
|
||||||
|
Releases []Release `json:"releases"`
|
||||||
|
// Information to uniquely identify the publisher of this package.
|
||||||
|
Publisher *ReleasePackagePublisher `json:"publisher"`
|
||||||
|
// A link to the license that applies to the data in this package.
|
||||||
|
License string `json:"license,omitempty"`
|
||||||
|
// A link to a document describing the publishers [publication
|
||||||
|
// policy](https://standard.open-contracting.org/{{version}}/{{lang}}/guidance/publish/#finalize-your-publication-policy).
|
||||||
|
PublicationPolicy string `json:"publicationPolicy,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleasePackagePublisher: Information to uniquely identify the publisher of this package.
|
||||||
|
type ReleasePackagePublisher struct {
|
||||||
|
// The name of the organization or department responsible for publishing this data.
|
||||||
|
Name string `json:"name"`
|
||||||
|
// The scheme that holds the unique identifiers used to identify the item being identified.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The unique ID for this entity under the given ID scheme.
|
||||||
|
Uid string `json:"uid,omitempty"`
|
||||||
|
// A URI to identify the publisher.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release: Each release provides data about a single contracting process at a particular
|
||||||
|
// point in time.
|
||||||
|
type Release struct {
|
||||||
|
// A globally unique identifier for this Open Contracting Process.
|
||||||
|
OCID string `json:"ocid"`
|
||||||
|
// An identifier for this particular release of information.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// The date on which the information contained in the release was first recorded in, or
|
||||||
|
// published by, any system.
|
||||||
|
Date time.Time `json:"date"`
|
||||||
|
// One or more values from the closed
|
||||||
|
// [releaseTag](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#release-tag)
|
||||||
|
// codelist. Codelist: releaseTag.csv (closed).
|
||||||
|
Tag []string `json:"tag"`
|
||||||
|
// The type of initiation process used for this contract, from the closed
|
||||||
|
// [initiationType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#initiation-type)
|
||||||
|
// codelist. Codelist: initiationType.csv (closed).
|
||||||
|
InitiationType string `json:"initiationType"`
|
||||||
|
// Information on the parties (organizations, economic operators and other participants) who
|
||||||
|
// are involved in the contracting process and their roles, e.g.
|
||||||
|
Parties []Organization `json:"parties,omitempty"`
|
||||||
|
// A buyer is an entity whose budget will be used to pay for goods, works or services related
|
||||||
|
// to a contract.
|
||||||
|
Buyer *OrganizationReference `json:"buyer,omitempty"`
|
||||||
|
// Information from the planning phase of the contracting process.
|
||||||
|
Planning *Planning `json:"planning,omitempty"`
|
||||||
|
// The activities undertaken in order to enter into a contract.
|
||||||
|
Tender *Tender `json:"tender,omitempty"`
|
||||||
|
// Information from the award phase of the contracting process.
|
||||||
|
Awards []Award `json:"awards,omitempty"`
|
||||||
|
// Information from the contract creation phase of the procurement process.
|
||||||
|
Contracts []Contract `json:"contracts,omitempty"`
|
||||||
|
// The default language of the data using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process follows on from one or more
|
||||||
|
// other processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address: An address.
|
||||||
|
type Address struct {
|
||||||
|
// The street address.
|
||||||
|
StreetAddress string `json:"streetAddress,omitempty"`
|
||||||
|
// The locality.
|
||||||
|
Locality string `json:"locality,omitempty"`
|
||||||
|
// The region.
|
||||||
|
Region string `json:"region,omitempty"`
|
||||||
|
// The postal code.
|
||||||
|
PostalCode string `json:"postalCode,omitempty"`
|
||||||
|
// The country name.
|
||||||
|
CountryName string `json:"countryName,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amendment: Amendment information
|
||||||
|
type Amendment struct {
|
||||||
|
// The date of this amendment.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// An explanation for the amendment.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// An identifier for this amendment: often the amendment number
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// A free text, or semi-structured, description of the changes made in this amendment.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **before** the amendment was made.
|
||||||
|
AmendsReleaseID string `json:"amendsReleaseID,omitempty"`
|
||||||
|
// Provide the identifier (release.id) of the OCDS release (from this contracting process)
|
||||||
|
// that provides the values for this contracting process **after** the amendment was made.
|
||||||
|
ReleaseID string `json:"releaseID,omitempty"`
|
||||||
|
// An array of change objects describing the fields changed, and their former values.
|
||||||
|
// Deprecated: since OCDS 1.1. A free-text or semi-structured string describing the changes
|
||||||
|
// made in each amendment can be provided in the amendment.description field.
|
||||||
|
Changes []AmendmentChanges `json:"changes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AmendmentChanges struct {
|
||||||
|
// The property name that has been changed relative to the place the amendment is.
|
||||||
|
Property string `json:"property,omitempty"`
|
||||||
|
// The previous value of the changed property, in whatever type the property is.
|
||||||
|
FormerValue json.RawMessage `json:"former_value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Award: An award for the given procurement.
|
||||||
|
type Award struct {
|
||||||
|
// The identifier for this award.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Award title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Award description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the award, from the closed
|
||||||
|
// [awardStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-status)
|
||||||
|
// codelist. Codelist: awardStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The date of the contract award.
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The total value of this award.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The suppliers awarded this award.
|
||||||
|
Suppliers []OrganizationReference `json:"suppliers,omitempty"`
|
||||||
|
// The goods and services awarded in this award, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The period for which the contract has been awarded.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// All documents and attachments related to the award, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// An award amendment is a formal change to the details of the award, and generally involves
|
||||||
|
// the publication of a new award notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Budget: This section contains information about the budget line, and associated projects,
|
||||||
|
// through which this contracting process is funded.
|
||||||
|
type Budget struct {
|
||||||
|
// An identifier for the budget line item which provides funds for this contracting process.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A short free text description of the budget source.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The value reserved in the budget for this contracting process.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// The name of the project through which this contracting process is funded (if applicable).
|
||||||
|
Project string `json:"project,omitempty"`
|
||||||
|
// An external identifier for the project that this contracting process forms part of, or is
|
||||||
|
// funded via (if applicable).
|
||||||
|
ProjectID ID `json:"projectID,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about the budget line-item or
|
||||||
|
// line-items that fund this contracting process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1) Used to point either to a corresponding Budget Data Package, or to a
|
||||||
|
// machine or human-readable source where users can find further information on the budget
|
||||||
|
// line item identifiers, or project identifiers, provided here.
|
||||||
|
// Deprecated: since OCDS 1.1. The budget data source field was intended to link to
|
||||||
|
// machine-readable data about the budget for a contracting process, but has been widely
|
||||||
|
// mis-used to provide free-text descriptions of budget providers.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Classification: A classification consists of at least two parts: an identifier for the list
|
||||||
|
// (scheme) from which the classification is taken, and an identifier for the category from
|
||||||
|
// that list being applied.
|
||||||
|
type Classification struct {
|
||||||
|
// The scheme or codelist from which the classification code is taken. Codelist:
|
||||||
|
// itemClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The classification code taken from the scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// A textual description or title for the classification code.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A URI to uniquely identify the classification code.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContactPoint: A person, contact point or department to contact in relation to this
|
||||||
|
// contracting process.
|
||||||
|
type ContactPoint struct {
|
||||||
|
// The name of the contact person, department, or contact point, for correspondence relating
|
||||||
|
// to this contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The e-mail address of the contact point/person.
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
// The telephone number of the contact point/person.
|
||||||
|
Telephone string `json:"telephone,omitempty"`
|
||||||
|
// The fax number of the contact point/person.
|
||||||
|
FaxNumber string `json:"faxNumber,omitempty"`
|
||||||
|
// A web address for the contact point/person.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract: Information regarding the signed contract between the buyer and supplier(s).
|
||||||
|
type Contract struct {
|
||||||
|
// The identifier for this contract.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// The award.id against which this contract is being issued.
|
||||||
|
AwardID ID `json:"awardID"`
|
||||||
|
// Contract title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// Contract description
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the contract, from the closed
|
||||||
|
// [contractStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#contract-status)
|
||||||
|
// codelist. Codelist: contractStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The start and end date for the contract.
|
||||||
|
Period *Period `json:"period,omitempty"`
|
||||||
|
// The total value of this contract.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The goods, services, and any intangible outcomes in this contract.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The date the contract was signed.
|
||||||
|
DateSigned *time.Time `json:"dateSigned,omitempty"`
|
||||||
|
// All documents and attachments related to the contract, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// Information related to the implementation of the contract in accordance with the
|
||||||
|
// obligations laid out therein.
|
||||||
|
Implementation *Implementation `json:"implementation,omitempty"`
|
||||||
|
// The details of related processes: for example, if this process is followed by one or more
|
||||||
|
// contracting processes, represented under a separate open contracting identifier (ocid).
|
||||||
|
RelatedProcesses []RelatedProcess `json:"relatedProcesses,omitempty"`
|
||||||
|
// A list of milestones associated with the finalization of this contract.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A contract amendment is a formal change to, or extension of, a contract, and generally
|
||||||
|
// involves the publication of a new contract notice/release, or some other documents
|
||||||
|
// detailing the change.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Document: Links to, or descriptions of, external documents can be attached at various
|
||||||
|
// locations within the standard.
|
||||||
|
type Document struct {
|
||||||
|
// A local, unique identifier for this document.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A classification of the document described, using the open
|
||||||
|
// [documentType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#document-type)
|
||||||
|
// codelist. Codelist: documentType.csv (open).
|
||||||
|
DocumentType string `json:"documentType,omitempty"`
|
||||||
|
// The document title.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A short description of the document.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// A direct link to the document or attachment.
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
// The date on which the document was first published.
|
||||||
|
DatePublished *time.Time `json:"datePublished,omitempty"`
|
||||||
|
// Date that the document was last modified
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The format of the document, using the open [IANA Media
|
||||||
|
// Types](https://www.iana.org/assignments/media-types/media-types.xhtml) codelist (see the
|
||||||
|
// values in the 'Template' column), or using the 'offline/print' code if the described
|
||||||
|
// document is published offline.
|
||||||
|
Format string `json:"format,omitempty"`
|
||||||
|
// The language of the linked document using either two-letter
|
||||||
|
// [ISO639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), or extended [BCP47
|
||||||
|
// language tags](https://www.w3.org/International/articles/language-tags/).
|
||||||
|
Language string `json:"language,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identifier: A unique identifier for a party (organization).
|
||||||
|
type Identifier struct {
|
||||||
|
// Organization identifiers should be taken from an existing organization identifier list.
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the organization in the selected scheme.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The legally registered name of the organization.
|
||||||
|
LegalName string `json:"legalName,omitempty"`
|
||||||
|
// A URI to identify the organization, such as those provided by [Open
|
||||||
|
// Corporates](https://opencorporates.com) or some other relevant URI provider.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementation: Information during the performance / implementation stage of the contract.
|
||||||
|
type Implementation struct {
|
||||||
|
// A list of the spending transactions made against this contract
|
||||||
|
Transactions []Transaction `json:"transactions,omitempty"`
|
||||||
|
// As milestones are completed, the milestone's status and dates should be updated.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// Documents and reports that are part of the implementation phase e.g.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Item: A good, service, or work to be contracted.
|
||||||
|
type Item struct {
|
||||||
|
// A local identifier to reference and merge the items by.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A description of the goods, services to be provided.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The primary classification for the item.
|
||||||
|
Classification *Classification `json:"classification,omitempty"`
|
||||||
|
// An array of additional classifications for the item.
|
||||||
|
AdditionalClassifications []Classification `json:"additionalClassifications,omitempty"`
|
||||||
|
// The number of units to be provided.
|
||||||
|
Quantity *float64 `json:"quantity,omitempty"`
|
||||||
|
// A description of the unit in which the supplies, services or works are provided (e.g.
|
||||||
|
Unit *ItemUnit `json:"unit,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemUnit: A description of the unit in which the supplies, services or works are provided
|
||||||
|
// (e.g.
|
||||||
|
type ItemUnit struct {
|
||||||
|
// The list from which identifiers for units of measure are taken, using the open
|
||||||
|
// [unitClassificationScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#unit-classification-scheme)
|
||||||
|
// codelist. Codelist: unitClassificationScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier from the codelist referenced in the `scheme` field.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// Name of the unit.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The monetary value of a single unit.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The machine-readable URI for the unit of measure, provided by the scheme.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Milestone: The milestone block can be used to represent a wide variety of events in the
|
||||||
|
// lifetime of a contracting process.
|
||||||
|
type Milestone struct {
|
||||||
|
// A local identifier for this milestone, unique within this block.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Milestone title
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The nature of the milestone, using the open
|
||||||
|
// [milestoneType](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-type)
|
||||||
|
// codelist. Codelist: milestoneType.csv (open).
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
// A description of the milestone.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// Milestone codes can be used to track specific events that take place for a particular kind
|
||||||
|
// of contracting process.
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
// The date the milestone is due.
|
||||||
|
DueDate *time.Time `json:"dueDate,omitempty"`
|
||||||
|
// The date on which the milestone was met.
|
||||||
|
DateMet *time.Time `json:"dateMet,omitempty"`
|
||||||
|
// The date the milestone was last reviewed or modified and the status was altered or
|
||||||
|
// confirmed to still be correct.
|
||||||
|
DateModified *time.Time `json:"dateModified,omitempty"`
|
||||||
|
// The status that was realized on the date provided in `dateModified`, from the closed
|
||||||
|
// [milestoneStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#milestone-status)
|
||||||
|
// codelist. Codelist: milestoneStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// List of documents associated with this milestone (Deprecated in 1.1).
|
||||||
|
// Deprecated: since OCDS 1.1. Inclusion of documents at the milestone level is now
|
||||||
|
// deprecated.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Organization: A party (organization)
|
||||||
|
type Organization struct {
|
||||||
|
// A common name for this organization or other participant in the contracting process.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The ID used for cross-referencing to this party from other sections of the release.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization or participant.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// A list of additional / supplemental identifiers for the organization or participant, using
|
||||||
|
// the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// An address.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// Contact details that can be used for this party.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
// The party's role(s) in the contracting process, using the open
|
||||||
|
// [partyRole](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#party-role)
|
||||||
|
// codelist. Codelist: partyRole.csv (open).
|
||||||
|
Roles []string `json:"roles,omitempty"`
|
||||||
|
// Additional classification information about parties can be provided using partyDetail
|
||||||
|
// extensions that define particular fields and classification schemes.
|
||||||
|
Details map[string]any `json:"details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationReference: The id and name of the party being referenced.
|
||||||
|
type OrganizationReference struct {
|
||||||
|
// The name of the party being referenced.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// The id of the party being referenced.
|
||||||
|
ID ID `json:"id,omitempty"`
|
||||||
|
// The primary identifier for this organization.
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and detailed legal identifier information should only be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
Identifier *Identifier `json:"identifier,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and address information should only be provided in the
|
||||||
|
// relevant cross-referenced entry in the parties section at the top level of a release.
|
||||||
|
Address *Address `json:"address,omitempty"`
|
||||||
|
// (Deprecated outside the parties section) A list of additional / supplemental identifiers
|
||||||
|
// for the organization, using the [organization identifier
|
||||||
|
// guidance](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/identifiers/).
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and additional identifiers for an organization should be
|
||||||
|
// provided in the relevant cross-referenced entry in the parties section at the top level of
|
||||||
|
// a release.
|
||||||
|
AdditionalIdentifiers []Identifier `json:"additionalIdentifiers,omitempty"`
|
||||||
|
// (Deprecated outside the parties section)
|
||||||
|
// Deprecated: since OCDS 1.1. From version 1.1, organizations should be referenced by their
|
||||||
|
// identifier and name in a document, and contact point information for an organization should
|
||||||
|
// be provided in the relevant cross-referenced entry in the parties section at the top level
|
||||||
|
// of a release.
|
||||||
|
ContactPoint *ContactPoint `json:"contactPoint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Period: Key events during a contracting process may have a known start date, end date,
|
||||||
|
// duration, or maximum extent (the latest date the period can extend to).
|
||||||
|
type Period struct {
|
||||||
|
// The start date for the period.
|
||||||
|
StartDate *time.Time `json:"startDate,omitempty"`
|
||||||
|
// The end date for the period.
|
||||||
|
EndDate *time.Time `json:"endDate,omitempty"`
|
||||||
|
// The period cannot be extended beyond this date.
|
||||||
|
MaxExtentDate *time.Time `json:"maxExtentDate,omitempty"`
|
||||||
|
// The maximum duration of this period in days.
|
||||||
|
DurationInDays *int `json:"durationInDays,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Planning: Information from the planning phase of the contracting process.
|
||||||
|
type Planning struct {
|
||||||
|
// The rationale for the procurement provided in free text.
|
||||||
|
Rationale string `json:"rationale,omitempty"`
|
||||||
|
// Details of the budget that funds this contracting process.
|
||||||
|
Budget *Budget `json:"budget,omitempty"`
|
||||||
|
// A list of documents related to the planning process.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the planning stage.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RelatedProcess: A reference to a related contracting process: generally one preceding or
|
||||||
|
// following on from the current process.
|
||||||
|
type RelatedProcess struct {
|
||||||
|
// A local identifier for this relationship, unique within this array.
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
// The type of relationship, using the open
|
||||||
|
// [relatedProcess](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process)
|
||||||
|
// codelist. Codelist: relatedProcess.csv (open).
|
||||||
|
Relationship []string `json:"relationship,omitempty"`
|
||||||
|
// The title of the related process, where referencing an open contracting process, this field
|
||||||
|
// should match the tender/title field in the related process.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// The identification scheme used by this cross-reference, using the open
|
||||||
|
// [relatedProcessScheme](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#related-process-scheme)
|
||||||
|
// codelist. Codelist: relatedProcessScheme.csv (open).
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
// The identifier of the related process.
|
||||||
|
Identifier string `json:"identifier,omitempty"`
|
||||||
|
// A URI pointing to a machine-readable document, release or record package containing the
|
||||||
|
// identified related process.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tender: Data regarding tender process - publicly inviting prospective contractors to submit
|
||||||
|
// bids for evaluation and selecting a winner or winners.
|
||||||
|
type Tender struct {
|
||||||
|
// An identifier for this tender process.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// A title for this tender.
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
// A summary description of the tender.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// The current status of the tender, from the closed
|
||||||
|
// [tenderStatus](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#tender-status)
|
||||||
|
// codelist. Codelist: tenderStatus.csv (closed).
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// The entity managing the procurement.
|
||||||
|
ProcuringEntity *OrganizationReference `json:"procuringEntity,omitempty"`
|
||||||
|
// The goods and services to be purchased, broken into line items wherever possible.
|
||||||
|
Items []Item `json:"items,omitempty"`
|
||||||
|
// The total upper estimated value of the procurement.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// The minimum estimated value of the procurement.
|
||||||
|
MinValue *Value `json:"minValue,omitempty"`
|
||||||
|
// The procurement method, from the closed
|
||||||
|
// [method](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#method)
|
||||||
|
// codelist. Codelist: method.csv (closed).
|
||||||
|
ProcurementMethod string `json:"procurementMethod,omitempty"`
|
||||||
|
// Additional detail on the procurement method used.
|
||||||
|
ProcurementMethodDetails string `json:"procurementMethodDetails,omitempty"`
|
||||||
|
// Rationale for the chosen procurement method.
|
||||||
|
ProcurementMethodRationale string `json:"procurementMethodRationale,omitempty"`
|
||||||
|
// The primary category describing the main object of this contracting process, from the
|
||||||
|
// closed
|
||||||
|
// [procurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#procurement-category)
|
||||||
|
// codelist. Codelist: procurementCategory.csv (closed).
|
||||||
|
MainProcurementCategory string `json:"mainProcurementCategory,omitempty"`
|
||||||
|
// Any additional categories describing the objects of this contracting process, using the
|
||||||
|
// open
|
||||||
|
// [extendedProcurementCategory](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#extended-procurement-category)
|
||||||
|
// codelist. Codelist: extendedProcurementCategory.csv (open).
|
||||||
|
AdditionalProcurementCategories []string `json:"additionalProcurementCategories,omitempty"`
|
||||||
|
// The award criteria for the procurement, using the open
|
||||||
|
// [awardCriteria](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#award-criteria)
|
||||||
|
// codelist. Codelist: awardCriteria.csv (open).
|
||||||
|
AwardCriteria string `json:"awardCriteria,omitempty"`
|
||||||
|
// Any detailed or further information on the award or selection criteria.
|
||||||
|
AwardCriteriaDetails string `json:"awardCriteriaDetails,omitempty"`
|
||||||
|
// The methods by which bids are submitted, using the open
|
||||||
|
// [submissionMethod](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#submission-method)
|
||||||
|
// codelist. Codelist: submissionMethod.csv (open).
|
||||||
|
SubmissionMethod []string `json:"submissionMethod,omitempty"`
|
||||||
|
// Any detailed or further information on the submission method.
|
||||||
|
SubmissionMethodDetails string `json:"submissionMethodDetails,omitempty"`
|
||||||
|
// The period when the tender is open for submissions.
|
||||||
|
TenderPeriod *Period `json:"tenderPeriod,omitempty"`
|
||||||
|
// The period during which potential bidders may submit questions and requests for
|
||||||
|
// clarification to the entity managing procurement.
|
||||||
|
EnquiryPeriod *Period `json:"enquiryPeriod,omitempty"`
|
||||||
|
// A true/false field to indicate whether any enquiries were received during the tender
|
||||||
|
// process.
|
||||||
|
HasEnquiries *bool `json:"hasEnquiries,omitempty"`
|
||||||
|
// A description of any eligibility criteria for potential suppliers.
|
||||||
|
EligibilityCriteria string `json:"eligibilityCriteria,omitempty"`
|
||||||
|
// The period for decision making regarding the contract award.
|
||||||
|
AwardPeriod *Period `json:"awardPeriod,omitempty"`
|
||||||
|
// The period over which the contract is estimated or required to be active.
|
||||||
|
ContractPeriod *Period `json:"contractPeriod,omitempty"`
|
||||||
|
// The number of parties who submit a bid.
|
||||||
|
NumberOfTenderers *int `json:"numberOfTenderers,omitempty"`
|
||||||
|
// All parties who submit a bid on a tender.
|
||||||
|
Tenderers []OrganizationReference `json:"tenderers,omitempty"`
|
||||||
|
// All documents and attachments related to the tender, including any notices.
|
||||||
|
Documents []Document `json:"documents,omitempty"`
|
||||||
|
// A list of milestones associated with the tender.
|
||||||
|
Milestones []Milestone `json:"milestones,omitempty"`
|
||||||
|
// A tender amendment is a formal change to the tender, and generally involves the publication
|
||||||
|
// of a new tender notice/release.
|
||||||
|
Amendments []Amendment `json:"amendments,omitempty"`
|
||||||
|
// The use of individual amendment objects has been deprecated.
|
||||||
|
// Deprecated: since OCDS 1.1. The single amendment object has been deprecated in favour of
|
||||||
|
// including amendments in an amendments (plural) array.
|
||||||
|
Amendment *Amendment `json:"amendment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction: A spending transaction related to the contracting process.
|
||||||
|
type Transaction struct {
|
||||||
|
// A unique identifier for this transaction.
|
||||||
|
ID ID `json:"id"`
|
||||||
|
// Used to point either to a corresponding Fiscal Data Package, IATI file, or machine or
|
||||||
|
// human-readable source where users can find further information on the budget line item
|
||||||
|
// identifiers, or project identifiers, provided here.
|
||||||
|
Source string `json:"source,omitempty"`
|
||||||
|
// The date of the transaction
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
// The value of the transaction.
|
||||||
|
Value *Value `json:"value,omitempty"`
|
||||||
|
// An organization reference for the organization from which the funds in this transaction
|
||||||
|
// originate.
|
||||||
|
Payer *OrganizationReference `json:"payer,omitempty"`
|
||||||
|
// An organization reference for the organization which receives the funds in this
|
||||||
|
// transaction.
|
||||||
|
Payee *OrganizationReference `json:"payee,omitempty"`
|
||||||
|
// A URI pointing directly to a machine-readable record about this spending transaction.
|
||||||
|
URI string `json:"uri,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.value` field
|
||||||
|
// for consistency with the use of value and amount elsewhere in the standard.
|
||||||
|
Amount *Value `json:"amount,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payer` field
|
||||||
|
// to resolve ambiguity arising from 'provider' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ProviderOrganization *Identifier `json:"providerOrganization,omitempty"`
|
||||||
|
// (Deprecated in 1.1.
|
||||||
|
// Deprecated: since OCDS 1.1. This field has been replaced by the `transaction.payee` field
|
||||||
|
// to resolve ambiguity arising from 'receiver' being interpreted as relating to the goods or
|
||||||
|
// services procured rather than the flow of funds between the parties.
|
||||||
|
ReceiverOrganization *Identifier `json:"receiverOrganization,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value: Financial values should be published with a currency attached.
|
||||||
|
type Value struct {
|
||||||
|
// Amount as a number.
|
||||||
|
Amount *float64 `json:"amount,omitempty"`
|
||||||
|
// The currency of the amount, from the closed
|
||||||
|
// [currency](https://standard.open-contracting.org/{{version}}/{{lang}}/schema/codelists/#currency)
|
||||||
|
// codelist. Codelist: currency.csv (closed).
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID is used for schema fields typed as ["string", "integer"], such as Item.id
|
||||||
|
// and Award.id. It accepts a JSON string or number and always encodes as a string.
|
||||||
|
type ID string
|
||||||
|
|
||||||
|
func (id *ID) UnmarshalJSON(b []byte) error {
|
||||||
|
if string(b) == "null" {
|
||||||
|
*id = ""
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal(b, &s); err == nil {
|
||||||
|
*id = ID(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var n json.Number
|
||||||
|
if err := json.Unmarshal(b, &n); err != nil {
|
||||||
|
return fmt.Errorf("ID must be a string or integer, got %s", b)
|
||||||
|
}
|
||||||
|
*id = ID(n.String())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": [
|
||||||
|
"https://standard.open-contracting.org/profiles/eu/latest/en/extension.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Package uk contains OCDS 1.1 types for the UK profile (UK extension and its dependencies, plus Lots and Pagination).
|
||||||
|
package eu
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p eu
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": [
|
||||||
|
"https://standard.open-contracting.org/profiles/eu/latest/en/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_amendment_rationale_classifications_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_budget_breakdown_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_contract_completion_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_documentation_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_pagination_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_suitability_extension/master/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/portaledcahn/ocds_Links_extension/main/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/cabinetoffice/ocds_uk_extension/main/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_performance_failures_extension/master/extension.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// Package full contains OCDS 1.1 types with the full extension set applied:
|
||||||
|
// the EU profile, UK extension, and the other extensions in extensions.json.
|
||||||
|
package findtender
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p findtender
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,46 @@
|
|||||||
|
package findtender
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestRoundTrip decodes a release package that uses several extensions and
|
||||||
|
// checks that re-encoding it loses nothing. Numeric IDs are the one expected
|
||||||
|
// change: ID always encodes as a string.
|
||||||
|
func TestRoundTrip(t *testing.T) {
|
||||||
|
in, err := os.ReadFile("testdata/release-package.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var pkg ReleasePackage
|
||||||
|
if err := json.Unmarshal(in, &pkg); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := pkg.Releases[0]
|
||||||
|
if got := r.Tender.Items[0].ID; got != "1" {
|
||||||
|
t.Errorf("numeric item id: got %q, want \"1\"", got)
|
||||||
|
}
|
||||||
|
if !*r.Tender.Lots[0].Suitability.SME {
|
||||||
|
t.Error("lot suitability lost")
|
||||||
|
}
|
||||||
|
if got := r.Contracts[0].Implementation.PerformanceFailures[0].ID; got != "PF1" {
|
||||||
|
t.Errorf("performance failure: got %q", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := json.Marshal(pkg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var want, got any
|
||||||
|
json.Unmarshal(in, &want)
|
||||||
|
json.Unmarshal(out, &got)
|
||||||
|
// Normalise the one numeric ID in the fixture before comparing.
|
||||||
|
want.(map[string]any)["releases"].([]any)[0].(map[string]any)["tender"].(map[string]any)["items"].([]any)[0].(map[string]any)["id"] = "1"
|
||||||
|
if !reflect.DeepEqual(want, got) {
|
||||||
|
t.Fatalf("round trip changed the data:\n%s", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"uri": "https://example.com/packages/1.json",
|
||||||
|
"version": "1.1",
|
||||||
|
"publishedDate": "2026-09-01T00:00:00Z",
|
||||||
|
"publisher": {"name": "Example Publisher"},
|
||||||
|
"links": {"next": "https://example.com/packages/2.json"},
|
||||||
|
"releases": [
|
||||||
|
{
|
||||||
|
"ocid": "ocds-abc123-0001",
|
||||||
|
"id": "0001-award",
|
||||||
|
"date": "2026-09-01T09:00:00Z",
|
||||||
|
"tag": ["award", "contract"],
|
||||||
|
"initiationType": "tender",
|
||||||
|
"links": [{"rel": "self", "href": "https://example.com/releases/0001"}],
|
||||||
|
"planning": {
|
||||||
|
"budget": {
|
||||||
|
"id": "B1",
|
||||||
|
"budgetBreakdown": [{"id": "BB1", "amount": {"amount": 1000000, "currency": "EUR"}}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tender": {
|
||||||
|
"id": "T1",
|
||||||
|
"title": "Road maintenance",
|
||||||
|
"lots": [{"id": "L1", "title": "North", "suitability": {"sme": true}}],
|
||||||
|
"items": [{"id": 1, "description": "Resurfacing", "relatedLot": "L1"}],
|
||||||
|
"documents": [{"id": "D1", "relatedLots": ["L1"], "pageStart": "4", "pageEnd": "9"}]
|
||||||
|
},
|
||||||
|
"awards": [{"id": "A1", "relatedLots": ["L1"], "status": "active"}],
|
||||||
|
"contracts": [{
|
||||||
|
"id": "C1",
|
||||||
|
"awardID": "A1",
|
||||||
|
"amendments": [{"id": "AM1", "rationaleClassifications": [{"scheme": "eu-modification-justification", "id": "add-wss"}]}],
|
||||||
|
"implementation": {
|
||||||
|
"endDate": "2027-06-30T00:00:00Z",
|
||||||
|
"finalValue": {"amount": 950000, "currency": "EUR"},
|
||||||
|
"performanceFailures": [{"id": "PF1", "description": "Late delivery"}]
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||||
|
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||||
|
"extensions": [
|
||||||
|
"https://standard.open-contracting.org/profiles/eu/latest/en/extension.json",
|
||||||
|
"https://raw.githubusercontent.com/cabinetoffice/ocds_uk_extension/main/extension.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Package uk contains OCDS 1.1 types for the UK profile (UK extension and its dependencies, plus Lots and Pagination).
|
||||||
|
package uk
|
||||||
|
|
||||||
|
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p uk
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user