351 Commits

Author SHA1 Message Date
Wolfgang Bumiller
f4e88aab6c api-macro: replace unreachable with a panic
(we're not running into this, but ran into an unreachable in
`syn` during development, and I needed to make sure it's not
one of ours...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:56:48 +01:00
Wolfgang Bumiller
dc4ec65723 api-macro: correctly infer newtype types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:10:22 +01:00
Wolfgang Bumiller
67949bf8f0 api-macro: factor handle_struct differently
Don't assume an empty object schema for all cases as
newtypes shouldn't use an object schema at all actually!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 10:53:59 +01:00
Wolfgang Bumiller
d7be7df86c bump proxmox-api-macro to 0.1.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:10:40 +01:00
Wolfgang Bumiller
dd8ccd80d9 api-macro: make API_{RETURN,PARAMETER}_SCHEMA_... public
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:08:59 +01:00
Wolfgang Bumiller
39566afb15 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:37:26 +01:00
Wolfgang Bumiller
db741bfb81 bump api-macro to 0.1.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:35:28 +01:00
Wolfgang Bumiller
eadffcfc16 expose parameter schema as API_PARAMETER_SCHEMA_<methodname>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:32:22 +01:00
Wolfgang Bumiller
2c7b786cef expose return schema as API_RETURN_SCHEMA_<methodname>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:28:19 +01:00
Wolfgang Bumiller
a5373a9679 bump api-macro
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-23 13:16:50 +01:00
Wolfgang Bumiller
edebbf920a fix property sorting
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-23 13:15:59 +01:00
Wolfgang Bumiller
436bf05e0b merge api, sys and tools into proxmox directly
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-21 12:15:42 +01:00
Wolfgang Bumiller
f22b693800 macro: silence some warnings in tests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-15 14:10:58 +01:00
Fabian Grünbichler
a94de245f0 build: switch to debcargo
to autogenerate crate (build)-dependencies, and correct Provides
statements.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-15 12:02:47 +01:00
Wolfgang Bumiller
66d9d43cd4 bump api-macro to 0.1.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:29:15 +01:00
Wolfgang Bumiller
1992abf96e api-macro: even more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:28:00 +01:00
Wolfgang Bumiller
0f630a4cb8 api-macro: more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:23:48 +01:00
Wolfgang Bumiller
5b652dbad8 api-macro: schema tests for async fns
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:01:55 +01:00
Wolfgang Bumiller
943bc4de52 api-macro: more tests
Note that this one tests the fact that we do not do output
schema validation!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:58:27 +01:00
Wolfgang Bumiller
58158b495e api-macro: more invocation tests for api methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:56:45 +01:00
Wolfgang Bumiller
679ad01c03 api-macro: add expanded data to tests for verification
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:51:00 +01:00
Wolfgang Bumiller
08e1cf3c2f api-macro: support empty api macro on structs
The description comes from the doc comment, the field types
and description from field doc comments and types.
Previously we needed to add at least the hint that the
schema is an object schema. Now we support an empty #[api]
attribute as well.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:09:42 +01:00
Wolfgang Bumiller
7c6ebbdbf3 api-macro: support renamed struct fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:06:48 +01:00
Wolfgang Bumiller
2e63bf8422 api-macro: support rename_all in enums
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:29:56 +01:00
Wolfgang Bumiller
dd5cd3f311 api-macro: start using serde attribute helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:23:52 +01:00
Wolfgang Bumiller
799c993d63 api-macro: prepare to support serde::rename_all
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:17:20 +01:00
Wolfgang Bumiller
3626f57d2c api-macro: more option type handling
infer_type now also returns whether it was encapsualted in
an Option<>. So `type: String, optional: true` is now
inferred propertly from `Option<String>`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:37:34 +01:00
Wolfgang Bumiller
45af06f090 api-macro: derive optional values correctly
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:19:13 +01:00
Wolfgang Bumiller
46fe5832fb api-macro: reorganize field iteration
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:18:21 +01:00
Wolfgang Bumiller
9207e8aa9a api-macro: error on extraneous fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:16:12 +01:00
Wolfgang Bumiller
860a4fd0ad api-macro: add basic struct handling
- handle doc comments for descriptions
- infer fields from structs when possible
- perform some basic error checking

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:20 +01:00
Wolfgang Bumiller
e960a68b60 api-macro: factor out type inference for reuse with structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:08 +01:00
Wolfgang Bumiller
b9769de6b6 api-macro: split struct handling into newtype, regular, unit, ...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:11:04 +01:00
Wolfgang Bumiller
4c77a7fece api-macro: derive descriptions for structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:00:17 +01:00
Wolfgang Bumiller
f214bcb652 api-macro: drop unused dev-dependencies
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 14:25:09 +01:00
Wolfgang Bumiller
c52794b8ad api-macro: bump bytes to 0.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 12:45:07 +01:00
Fabian Grünbichler
8840877c80 proxmox-api-macro: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Wolfgang Bumiller
5e1468bff8 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:20:58 +01:00
Thomas Lamprecht
13007df318 api/macro: add NumberSchema
Adapted from the integer schema, uses f64 type.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 11:30:55 +01:00
Wolfgang Bumiller
1d65ff88dd drop derive-builder dependency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 10:00:30 +01:00
Wolfgang Bumiller
778983c1b0 remove old router macro documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 09:40:40 +01:00
Wolfgang Bumiller
79c9d6ab08 api-macro: remove now-unnecessary PropertySchema type
Schemas can now generally refer to an externally defined
schema.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 13:06:58 +01:00
Wolfgang Bumiller
3e5927a1b4 api-macro: generalized '{ schema: PATH }' schemas
allow 'schema: PATH' outside object property context

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 12:11:52 +01:00
Wolfgang Bumiller
808035f524 api-macro: support 'async fn' with new async api method
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 11:13:26 +01:00
Wolfgang Bumiller
6d152f8930 updates for hyper 0.13 release
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-12 13:13:53 +01:00
Wolfgang Bumiller
65a284784b clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 11:42:34 +01:00
Wolfgang Bumiller
7c48247c58 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 11:32:48 +01:00
Wolfgang Bumiller
b81beb4dfb api-macro: allow methods without return types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 14:27:57 +01:00
Wolfgang Bumiller
c282c8ce23 api-macro: don't return Null without return schema
serde_json turns () into Null anyway, so there's no need to
check this!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 14:25:12 +01:00
Wolfgang Bumiller
f9d775924d api-macro: get enum description from doc comments
instead of:
    #[api(description: "Some description.")]
    pub enum { ... }

support:
    #[api]
    /// Some description.
    pub enum { ... }

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 11:52:03 +01:00