Fix an error when variable in links can't be added to url#105
Open
exorevan wants to merge 1 commit intojtc42:mainfrom
Open
Fix an error when variable in links can't be added to url#105exorevan wants to merge 1 commit intojtc42:mainfrom
exorevan wants to merge 1 commit intojtc42:mainfrom
Conversation
Collaborator
|
Please add a unit test to show he new expected behaviour Another thing is that it is unexpected that Hypernodels are used as path params |
Author
|
Where should I put the test? Also what about #102 The example how it would work: from fastapi import FastAPI
from fastapi_hypermodel import FrozenDict, HALFor, HALLinks, HALHyperModel
app = FastAPI()
@app.get(path="/rest/{process}/{operation}", response_model=int)
def get_process(process: int, operation: str):
return process
class Process(HALHyperModel):
process: int
links: HALLinks = FrozenDict({
"self": HALFor("get_process", {
"process": "<process>", # internal model parameter
"operation": "wait" # external hardcoded parameter
})
})
HALHyperModel.init_app(app)
process_instance = Process(process=5)
assert "self" in process_instance.links
assert process_instance.links["self"].href == "/rest/5/wait"
process_instance_2 = Process(process=10)
assert process_instance_2.links["self"].href == "/rest/10/wait" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix an error when links build with not internal model variable. Method
resolve_param_valuesofAbstractHyperFielddeletes all rest parameters those are not got from HALHyperModel parameters. Now those parameters update original parameters dict.fixes #104
Error example: