spaceapi-kt

https://github.com/spaceapi-community/spaceapi-kt

License

License

Categories

Categories

Unity Business Logic Libraries Game Development
GroupId

GroupId

io.github.spaceapi-community
ArtifactId

ArtifactId

spaceapi-kt
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

spaceapi-kt
https://github.com/spaceapi-community/spaceapi-kt
Project URL

Project URL

https://github.com/spaceapi-community/spaceapi-kt
Source Code Management

Source Code Management

https://github.com/spaceapi-community/spaceapi-kt

Download spaceapi-kt

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.5.0
org.jetbrains.kotlinx : kotlinx-serialization-json-jvm jar 1.2.1

Project Modules

There are no modules declared in this project.

SpaceAPI Parser for Kotlin/Java

This is a parser library written in Kotlin that can be used from Kotlin and Java.

The parser is quite lenient, so it will ignore unknown fields, should be able to deal with multiple versions and will sometimes even parse invalid endpoint JSON. Additionally, in most cases, values with a fixed set of allowed values is parsed as String, not as enum. (If you need strict validation, use a JSON schema based validator instead!)

API Version Support

This library supports parsing any valid JSON file using the following schema version:

  • v0.13
  • v14

Note: Endpoints using versions 0.12 and older are not supported, they will result in a ParseError being thrown.

Installing

Gradle

First, ensure that the Maven Central repository is added to the gradle config:

repositories {
    mavenCentral()
}

Then, add the dependency to your build.gradle:

implementation 'io.github.spaceapi-community:spaceapi-kt:0.3.0'

Usage

Kotlin

import io.spaceapi.parseString

// ...

val parsed = parseString("{...}")

Java

import io.spaceapi.SpaceApiParser;
import io.spaceapi.types.Status;

// ...

final Status parsedStatus = SpaceApiParser.parseString("{...}");

Building

To build a JAR file, run:

./gradlew build

The resulting JAR files can be found in the build/libs/ directory.

Testing

Unit Tests

Run the following command to run the unit tests:

./gradlew test

Directory Parser

In the src/test/kotlin/io/spaceapi/ directory there's a DirectoryParser.kt program that can be executed. It fetches all directory endpoints and tests whether the endpoint can be deserialized. If not, an error message is printed.

Manual testing

Create a local publication (usually at $HOME/.m2/repository/):

./gradlew publishToMavenLocal

Include it in your project like this:

repositories {
    ...
    mavenLocal()
}

Signing

Releases are signed with the following PGP public key:

pub   rsa4096 2012-03-03 [SC] [expires: 2022-03-01]
      EA456E8BAF0109429583EED83578F667F2F3A5FA
sub   rsa4096 2012-03-03 [E] [expires: 2022-03-01]

License

This project is licensed under the GNU General Public License v3.0 or later.

spaceapi-kt
Copyright (C) 2020-2021 Danilo Bargen

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 <https://www.gnu.org/licenses/>.
io.github.spaceapi-community

SpaceAPI Community

Community projects related to the SpaceAPI

Versions

Version
0.3.0
0.2.1