Skip to content

Commit

Permalink
#35: Rename @RESTapi to @apiservice
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeleon committed Jan 1, 2024
1 parent e3d6317 commit 6a6d133
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sources/Relax/API Structure/Macros/RestAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
import Foundation

@attached(extension, conformances: APIComponent, names: named(baseURL))
public macro RestAPI(_ baseURL: String) = #externalMacro(module: "RelaxMacros", type: "RestAPIMacro")
public macro APIService(_ baseURL: String) = #externalMacro(module: "RelaxMacros", type: "APIServiceMacro")
1 change: 0 additions & 1 deletion Sources/Relax/API Structure/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ import FoundationNetworking
///
/// A ``Service`` defines a REST API at the root level, and all ``Request``s and ``Endpoint``s which share a common base URL belong to the service.
/// You define common properties here which will be used by all requests that belong to the service.
@available(*, deprecated, renamed: "RestAPI", message: "Use the @RestAPI macro instead")
public typealias Service = APIComponent
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// RestAPIMacro.swift
// APIServiceMacro.swift
//
//
// Created by Thomas De Leon on 12/27/23.
Expand All @@ -9,7 +9,7 @@ import SwiftSyntax
import SwiftSyntaxBuilder
import SwiftSyntaxMacros

public struct RestAPIMacro: ExtensionMacro {
public struct APIServiceMacro: ExtensionMacro {
public static func expansion(
of node: AttributeSyntax,
attachedTo declaration: some DeclGroupSyntax,
Expand Down
2 changes: 1 addition & 1 deletion Sources/RelaxMacros/RelaxMacrosPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import SwiftSyntaxMacros
@main
struct RelaxMacrosPlugin: CompilerPlugin {
let providingMacros: [Macro.Type] = [
RestAPIMacro.self
APIServiceMacro.self
]
}
4 changes: 2 additions & 2 deletions Tests/RelaxTests/Helpers/MockServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import FoundationNetworking
#endif
@testable import Relax

@RestAPI("https://example.com")
@APIService("https://example.com")
enum ExampleService {
static var session: URLSession = .shared

Expand Down Expand Up @@ -135,7 +135,7 @@ enum ExampleService {
}
}

@RestAPI("a://@@")
@APIService("a://@@")
enum BadURLService {
@RequestBuilder<BadURLService>
static var get: Request {
Expand Down
4 changes: 2 additions & 2 deletions Tests/RelaxTests/MacroTests/MacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import XCTest
#if canImport(RelaxMacros)
import RelaxMacros
let testMacros: [String: Macro.Type] = [
"Service": RestAPIMacro.self
"APIService": APIServiceMacro.self
]
#endif

Expand All @@ -21,7 +21,7 @@ final class MacroTests: XCTestCase {
#if canImport(RelaxMacros)
assertMacroExpansion(
"""
@RestAPI
@APIService("https://example.com/")
enum TestService {
}
""",
Expand Down

0 comments on commit 6a6d133

Please sign in to comment.